WordPress show posts from children terms of a taxonomy term
WordPress show posts from children terms of a taxonomy term
WordPress show posts from children terms of a taxonomy term
First of all you want to add it only once, so you have to check if it exists. Then you can use wp_insert_term function if ( !term_exists(‘MyCategory1’, ‘genre’) ) { wp_insert_term(‘MyCategory1’, ‘genre’); }
Few remarks: I use pre_get_posts as an action hook, not as a filter. You should use ! is_admin() to prevent this from changing your backend views. You should skip the ‘relation’ => ‘OR’, since you only have a single tax_query filter Is there any reason why you have to modify the post type ? Is … Read more
It’s OK. The only problem I can see with this solution, is that you select all post data just to check if such post exists (and posts can be long). So I would consider using custom query in this case (it gives you number of posts with this term assigned) function my_count_posts_with_term($taxonomy, $term_slug, $post_type) { … Read more
Retrieve name or slug from get_objects_in_term
What makes the most sense for you to do is not to try to make covers themselves specifically show all your articles, but to make the archive page for your “Issues” taxonomy include both the cover and the articles. This is better both conceptually and practically. To to do it, I’ll assume your issues taxonomy … Read more
I solved this by keeping my three separate queries and building a complex system to handle paging manually. It’s not ideal, but I really saw no better way to do it.
Add one of your custom taxonomies to a wordpress menu, then click the menu item in frontend and you’ll see the correct url in the address bar. If this doesn’t fit your needs have a look at the “rewrite” part of the register_taxonomy() arguments.
Displaying or Hiding Metadata on Page from WP CPanel
You can use a taxonomy query, like this: $args = array( ‘post_type’ => ‘recipe’, ‘tax_query’ => array( array( ‘taxonomy’ => ‘types’, ‘field’ => ‘slug’, ‘terms’ => array( ‘vegetables’, ‘fruit’ ) ) ) ); $query = new WP_Query( $args );