WordPress slug issue with non-latin characters

I’m using permalinks in WP as: domain.com/category/post_name The issue is that post names have non-latin characters such as chinese, hebrew, and arabic. So it encodes them to something like: %20%18%6b%20 therefore it counts every symbol’s character as an actual character, ending up with 3x times more length that it truncates some very short slugs. How … Read more

custom taxonomy and pages rewrite slug conflict gives 404

I’m using the Custom Post Type UI plugin to create my custom taxonomies. I have a portfolio that is made up of projects (custom post type) with 2 custom taxonomies of technologies and clients. The clients taxonomy has a custom rewrite slug of portfolio/clients/, while the technologies taxonomy has a custom rewrite slug of portfolio/ … Read more

Change author base slug for different roles

Is it possible to change the author base slug according to his role? For example, authors get example.com/ninja/%username% and subscribers get example.com/trainee/%username%? I am thinking of something like: add_action(‘init’, ‘set_new_author_base’); function set_new_author_base() { global $wp_rewrite; if($user->role == ‘subscriber’) $author_slug = ‘trainee’; $wp_rewrite->author_base = $author_slug; } elseif($user->role == ‘author’) { $author_slug = ‘ninja’; $wp_rewrite->author_base = $author_slug; … Read more

Where is the old post permalink slug stored?

I published an article with permalink slug: http://domain.com/writing Then after publishing, I changed the permalink slug to writing-lorem. Now, whenever I visit /writing, it redirects to /writing-lorem. I want to use the writing slug for a new category but can’t, it changes to writing-2. To attempt to remove all records of the writing slug, I … Read more

How to check if a slug exists?

I have a arbitrary string and want to check if a post with that slug string exists in the site. I tried to find a way to list all slugs, but can’t find such a thing. Thanks 5 This is what you’re looking for, tested and I use it on my own sites: function the_slug_exists($post_name) … Read more

Custom Post Type Slug / Page Slug Conflict – Prevent use of reserved slug on page save?

I have a custom post type of portfolio (slug portfolio) in my theme and all is working well except one thing. When people create a page with a slug of portfolio, eg: example.com/portfolio, the theme thinks I’m wanting to use the custom post type archive page, not my page created in the editor. Can I … Read more

Is there a maximum slug length?

A client just created a post with a really long slug (90 characters), no special characters (other than hyphens) etc. Whenever the link to that post was clicked, including the “Preview” or “View this Post” links from the Admin back end, a 404 was generated. Once we manually trimmed the slug, everything worked as expected. … Read more

How to set post slug when using wp_insert_post();?

My theme uses a custom template to render some contents. To use this template, I’m hooking into after_switch_theme to create my own page after the theme is activated, and then assign this template to it. This is how I do it: $new_page_title = __(‘Custom page’); $new_page_content=””; $new_page_template=”page-custom.php”; $page_check = get_page_by_title($new_page_title); $new_page = array( ‘post_type’ => … Read more