1
votes

In Wordpress Permalink : I use /%category%/%postname%/

With categories like « News », « Formation », « Events » etc.. (true categories)

But I have some categories only for display features like « slider1 », « homepagedisplay » or some child category… (« false » categories)

And many posts, are both in « true » and « false » categories and get false cat for url structure... : test.com/slider1/my-post .....

  • I want to remove « false » categories from the « %category% »
    Permalink structure
    .
  • Is there a hook filter to do that in PHP ? Or a plugin to exclude them ?

Thanks for help

2

2 Answers

0
votes

If you want to not display the links to some categories, toy could add this IF to where the links printed:

$categories_not_to_print=array(
   'false'=>'',
   'true' => '',
   'slider one'=>'',
);
$categoires=get_the_category();

foreach($categoires as $category) {

   $cat_name=$category->name;

   if(!isset($categories_not_to_print[$cat_name])) {
       //Print only category if not on list
       echo $cat_name;
   }

}

If you want that the links wont work/redirect to somewhere else (EX: To prevent Google from indexing pages that with categories that mean nothing)?

In that case you could use a redirect plugin like https://wordpress.org/plugins/redirection/ to redirect the not real category links to home page/ 404 eroor page/ wherever you want.

0
votes

I find the plugin solution :

With it you can choose the master, on the category selection

https://wordpress.org/plugins/wp-category-permalink/