Thursday, February 16, 2023
HomeWordPress Developmentphp - Methods to make a number of customized taxonomies sit below...

php – Methods to make a number of customized taxonomies sit below customized submit sort slug?


I’ve a customized submit sort known as assets which has been registered as so:

register_post_type(
  'Sources',
  theme_build_post_args(
    // $slug, $singular, $plural
    'assets', 'Useful resource', 'Sources',
    array(
      'menu_position' => 20,
       'has_archive'    => true,
      //'has_archive'   => 'varieties',
      'public'          => true,
      'helps'            => array('title', 'revisions', 'thumbnail', 'editor', 'creator'),
      'taxonomies'      => array('matters', 'varieties', 'industries'),
      'rewrite' => array('slug' => 'assets/%varieties%')
    )
  )
);

This submit sort has three taxonomies which have been registered like this:

register_taxonomy(
  'matters',
  'matters',
  array(
    'hierarchical' => true,
    'label' => 'Matters',
    'query_var' => true,
    'show_admin_column' => true,
    'publicly_queryable' => true,
    // 'rewrite' => array('slug' => 'assets')
  )
);

register_taxonomy(
  'varieties',
  'varieties',
  array(
    'hierarchical' => true,
    'label' => 'Varieties',
    'query_var' => true,
    'show_admin_column' => true,
    'publicly_queryable' => true,
    // 'rewrite' => array('slug' => 'assets')
  )
);

register_taxonomy(
  'industries',
  'industries',
  array(
    'hierarchical' => true,
    'label' => 'Trade',
    'query_var' => true,
    'show_admin_column' => true,
    'publicly_queryable' => true,
    // 'rewrite' => array('slug' => 'assets')
  )
);

At the moment, when accessing a class outlined in any taxonomy, the slug ignores /assets. For instance, I’ve a sort known as Article. When accessing this web page, it sits on /varieties/article/ once I want it to sit down on /assets/varieties/article/.

The identical applies for matters and industries.

Now I’ve seen approaches stating this could do the trick:

'rewrite' => array('slug' => 'assets/%varieties%')

Nonetheless, the above does not work for varieties, that means varieties nonetheless don’t sit below /assets, but in addition, I want this to happen for 3 taxonomies, fairly than simply 1 and I can not rewrite slugs for 3 taxonomies.

How do I am going about this?

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments