Skip to content

Override Post Type and Taxonomy Registration Arguments

Table of Contents

Content Fields builds the arguments for register_post_type() and register_taxonomy() from what you set in the builder. Two filters let you change those arguments before WordPress sees them.

What It Does

nxt/register_post_type_args and nxt/register_taxonomy_args hand you the assembled argument array, the key, and the raw settings. Anything WordPress accepts can be set here, including options the builder does not expose.

Before You Start

  • Nexter Extension 4.9.0 or later with Content Fields enabled.
  • Somewhere to add PHP — a child theme, a small plugin, or a Nexter code snippet.
  • You know the key you want to affect.

Change Registration Arguments

  1. Add a filter on nxt/register_post_type_args (or the taxonomy equivalent) with three arguments.
The Post Types tab, where the arguments these filters override are set
  1. Test the $key so you only change the type you mean.
  1. Modify the argument array and return it.
  1. Save Settings → Permalinks once if you changed anything affecting URLs.

When to Use It

  • Setting a menu position or icon the builder does not offer.
  • Adding show_admin_column to a taxonomy so terms appear in the posts list.
  • Changing rewrite behaviour for one type only.

Display the Value

Adding an argument the builder does not expose:

<?php
add_filter( 'nxt/register_post_type_args', function ( $cpt_args, $key, $args ) {
    if ( 'property' !== $key ) {
        return $cpt_args;
    }
    $cpt_args['menu_position']      = 25;
    $cpt_args['show_in_admin_bar']  = false;
    $cpt_args['rewrite']['with_front'] = false;
    return $cpt_args;
}, 10, 3 );

add_filter( 'nxt/register_taxonomy_args', function ( $params, $key, $args ) {
    if ( 'property_type' === $key ) {
        $params['show_admin_column'] = true;
    }
    return $params;
}, 10, 3 );

Limitations

  • These run at registration time, so a change takes effect on the next page load — but URL changes still need a permalink flush.
  • Overriding the post type key here is a bad idea. Posts are stored against it, so changing it hides them.
  • The builder is unaware of your override, so its UI will keep showing the original setting.

Troubleshooting

My change has no effect

Check the $key test matches the actual post type key, and that the filter is loaded before init. A filter added too late misses registration.

URLs still 404 after a rewrite change

Save Settings → Permalinks once to flush the rewrite rules.

Related Docs

Share your Thoughts

Still in Doubt? Let’s Assist You

Have Feedback or Questions?

Join our WordPress Community on Facebook!