Must slugs be unique?

In wp_unique_term_slug(): The $slug has to be unique global to every taxonomy, meaning that one taxonomy term can’t have a matching slug with another taxonomy term. Each slug has to be globally unique for every taxonomy. In wp_unique_post_slug(): @param string $post_status no uniqueness checks are made if the post is still draft or pending […] … Read more

Removing the redirect after changing a page’s slug

This (in your functions.php) will turn it off (but see also the comment I’ve left): remove_action(‘template_redirect’, ‘wp_old_slug_redirect’); It seems odd that your wp_postmeta table wouldn’t have any _wp_old_slug keys – the bit of code that does that is in wp-includes/query.php (wp_old_slug_redirect()) – you could add an exit or debug statement there to check if it’s … Read more

How to get custom post type label and singular label from its slug?

get_post_type_object() will return, as the name suggests, an object that contains the post type information. You may want to var_dump() it to inspect it contents. You’ll see that it includes (among other stuff) another object, labels that contains all the registered labels for the specific post type. $pt = get_post_type_object( ‘books’ ); // These two … Read more

Use category base slug in posts’ permalink

I may be missing some vital detail in the question but here’s what I did to make this work. Settings -> Permalinks Set the permalinks to… /somePrefix/%category%/%postname%/ This will give you the following permalinks… Blog Page – domain.com/somePrefix Category Page – domain.com/somePrefix/currCategory/ Single Page – domain.com/somePrefix/currCategory/singlePost/ If you install some kind of plugin like Yoast … Read more

Force post slug to be auto generated from title on save

The easiest workaround could be: function myplugin_update_slug( $data, $postarr ) { if ( ! in_array( $data[‘post_status’], array( ‘draft’, ‘pending’, ‘auto-draft’ ) ) ) { $data[‘post_name’] = sanitize_title( $data[‘post_title’] ); } return $data; } add_filter( ‘wp_insert_post_data’, ‘myplugin_update_slug’, 99, 2 );

Using custom/dynamic “slug” for a page

Create a Page Template Add a new page and give it the slug stores Add A Public Query Variable add_filter(‘query_vars’, ‘add_state_var’, 0, 1); function add_state_var($vars){ $vars[] = ‘state’; return $vars; } Add a rewrite rule This will direct your request to your stores page. add_rewrite_rule(‘^stores/([^/]*)/?’,’index.php?post_type=page&name=stores&state=$matches[1]’,’top’); Within your Template You can access your state variable as … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)