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

How to get a taxonomy term name by the slug?

The function you are looking for is get_term_by. You would use it as such: <?php $term = get_term_by(‘slug’, ‘my-term-slug’, ‘category’); $name = $term->name; ?> This results in $term being an object containing the following: term_id name slug term_group term_taxonomy_id taxonomy description parent count The codex does a great job explaining this function: https://developer.wordpress.org/reference/functions/get_term_by/