1. Home
  2. Docs
  3. Filters & Hooks
  4. How to prevent the post slugs from being added to the default URIs?

How to prevent the post slugs from being added to the default URIs?

By default Permalink Manager automatically appends the post slugs to the end of custom permalink (the default one). To prevent the post slugs from being added to the default URI please use following snippets:

You can either limit the snippet to selected post types (eg. products and pages):

function pm_donot_append_slug($bool, $post_type) {
	return (in_array($post_type, array('product', 'page'))) ? true : $bool;
}
add_filter('permalink_manager_do_not_append_slug', 'pm_donot_append_slug', 9, 2);

… or do not append the slug to any post type default permalinks at all:

add_filter('permalink_manager_do_not_append_slug', '__return_true', 9, 2);
Was this article helpful to you? Yes No

How can we help?

Wait!!! Before you go...

Still not convinced? Use following discount code during Gumroad checkout and get 10% off!

BLOG

If you have any questions or need further information, please feel free to contact me via email: