CHOOSE ONLY ONE CATEGORY WORDPRESS
If you need to limit the number of categories used by the authors of your site, there is a trick for you.
This piece of PHP code limits the number of categories choosen by the authors who are using WordPress to edit post articles in your web sites.
The code works only in the backoffice side of WordPress, to do this it starts with
is_admin() check, then it hooks at
<div id="#category-all"> tag, and if the count is grater than the predefined
max variable value, it stops with a a simple
You can place this code at the bottom of your
functions.php file in your WordPress theme.
Limit categories to 1 for SEO purposes
Limit the number of categories choosen by your authors could be useful to better handle and organize your site navigation, but limit the categories to 1 can be very useful also for Search Engine Optimization, especially if you have the category name in your permalink structure.
If you have, for example, two categories for a post and you have the category slug in your permalink structure your WordPress will creates 2 urls for your post (
get_the_permalink() will return 1 url, but your post will be reached with both urls if you navigated throught caategory pages), which is a bad thing:
This is bad because for Google you’re site is duplicating contents, which is penalized by Google search engine.