set_object_terms for custom taxonomy in custom post type – not working
set_object_terms for custom taxonomy in custom post type – not working
set_object_terms for custom taxonomy in custom post type – not working
Since the queries are not related to each other, there is no other way around it. You are going to end with with many queries and slow page (when it is not cached) on a site with many categories. A better approch may be to show latest 50 posts, and display them by category, but … Read more
Actually it was happened for using public => false, when registering my post type. So, always use public => true, has_archieve => true & with_front => true if you want to display your single custom posts.
Since your first get_categories call will load all terms into memory, you can just loop over ’em and check if they have an ancestor with ID 55, and WordPress won’t ever hit the db again: $terms = get_terms([ ‘taxonomy’ => ‘category’, ‘hide_empty’ => false, ]); foreach ( $terms as $k => $term ) { if … Read more
Your permalink structure prefix is controlled by the with_front argument: ‘rewrite’ => array( ‘slug’ => ‘my_taxonomy’, ‘with_front’ => true, // changed to include prefix ‘hierarchical’ => false, ‘ep_mask’ => EP_NONE ),
Print Custom Taxonomy Term Name
Use this line of code for listing categories. $terms_list = get_terms(array(‘taxonomy’=>’category’, ‘hide_empty’=>FALSE, ‘parent’=>0)); print_r($terms_list);
I figured it out. I needed to add ‘orderby’ => ‘menu_order’, ‘order’ => ‘ASC’, to $related_posts = get_related_posts( ‘juryyear’, array( ‘posts_per_page’ => 99,) );
You’re almost there my friend. Just check with $query->is_tag() rather than only is_tag(). So your updated code will be- function main_query_mods( $query ) { // check http://codex.wordpress.org/Conditional_Tags to play with other queries if(!$query->is_main_query()) { return; } if($query->is_tag()) { $query->set(‘posts_per_page’,10); } } add_action( ‘pre_get_posts’, ‘main_query_mods’ );
I’d recommend using get_the_terms instead of get_terms. It specifically pulls out the terms that are attached to a given post. If you use it within the loop, it’ll only give you the terms that are attached to that post. It’d look something like this: $query = new WP_Query( $args ); if ( $query->have_posts() ) : … Read more