Broken paths on taxonomies after changing permalink to post name

I added a rewrite rule manually. add_rewrite_rule(‘^bar([^/]+)(/[0-9]+)?/?$’,’index.php?bar=$matches[1]’,’top’); right after add_action(‘init’, ‘register_taxonomy_bar’); in functions.php. But WordPress is SERIOUSLY DENSE in translating /bar/foo/ to barfoo?bar=foo and I don’t know how to get around this nonsensical “barfoo” in the path. I also have no idea what it’ll do to paging. Also this has to be defined for each … Read more

How do you search for a post by custom taxonomy?

For the record I found an answer to this question in the end – I needed to use a meta query rather than a taxonomy query. The correct code ended up being this: $relatedBlogPostArgs = array( ‘post_type’ => ‘post’, ‘post_status’ => ‘publish’, ‘posts_per_page’ => 1, ‘order’ => ‘DESC’, ‘orderby’ => ‘date’, ‘meta_query’ => array( array( … Read more

WordPress: insert a custom post type instance as an option for a custom taxonomy

Ok, so I’m feeling generous and will add another answer 🙂 This code will run every time a post is created or updated, and it will add a term to your teacher taxonomy with a name that is the same as the post title. add_action(‘save_post’, ‘my_create_teacher_term_from_post’); function my_project_updated_send_email($post_id){ /** Ensure that this is not a … Read more