WordPress slug issue with non-latin characters

Permalinks like http://example/שָׁלוֹם are actually working in my WordPress 3.3. Could be the remove_accents() improvements for i18n permalinks. As Sean & Steve noted, make sure you’re using WordPress ≥ 3.3 make sure your .htaccess file contains a rule similar to RewriteRule . /index.php [L] check that your database is UTF-8 encoded (and consider converting to … Read more

Change author base slug for different roles

In your example, the author rewrite pattern changes from /author/[authorname]/ to /[author_level]/[author_name]/. If we allow [author_level] to be anything, we will get into conflict with the rules for pages, because /[anything]/[anything]/ can be either an author archive or a regular subpage. For this reason, my solution assumes you have a limited number of author levels, … Read more

Can I use a number for a post/page slug?

It’s only Pages where this is an issue. Posts are fine. Seems like a bug to me, but regardless of whether or not it’s a bug, you can not use numeric slugs on pages. This is because number slugs like “/750/” interfere with posts years “/2010/” etc. and WordPress can’t tell the difference. If you … Read more

How to check if a slug exists?

This is what you’re looking for, tested and I use it on my own sites: function the_slug_exists($post_name) { global $wpdb; if($wpdb->get_row(“SELECT post_name FROM wp_posts WHERE post_name=”” . $post_name . “””, ‘ARRAY_A’)) { return true; } else { return false; } } You can then use it like this: if (the_slug_exists(‘contact’)) { // do something } … Read more

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

The following 2 filters allow you to hook into when WordPress checks the slug and are found in the function wp_unique_post_slug() in the wp-includes/post.php file. There are 2 filters, one for hierarchical posts and one for non-hierarchical. The hierarchical filter provides the ID for the post parent so if the $post_parent is 0, you know … Read more

Get page content using slug

Use get_posts() and the parameter name which is the slug: $page = get_posts([ ‘name’ => ‘your-slug’ ]); if ( $page ) { echo $page[0]->post_content; } Be aware that the post type in get_posts() defaults to ‘post’. If you want a page use … $page = get_posts([ ‘name’ => ‘your-slug’, ‘post_type’ => ‘page’ ]); If you … Read more

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