What’s the most efficient way to get two queries based on an if statement?
What’s the most efficient way to get two queries based on an if statement?
What’s the most efficient way to get two queries based on an if statement?
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,) );
One approach is to use JavaScript to add the maxlength attribute to the term description field: function wpse_term_description_attributes() { ?> <script type=”text/javascript”> jQuery(document).ready(function($) { $( ‘.taxonomy-custom_taxonomy_name #description, .taxonomy-custom_taxonomy_name #tag-description’ ).attr( ‘maxlength’, ’20’ ); }); </script><?php } add_action( ‘admin_head’, ‘wpse_term_description_attributes’ ); Replace custom_taxonomy_name with the name of your taxonomy, and customize the value assigned to the … Read more
Does your custom post type have the setting publicly_queryable=true? Check the post type in the resulting query to see if it matches your post type. I’m guessing that your post type ‘distribution_centre’ is not being queried for one reason or another. add_filter( ‘posts_request’, ‘dump_request’ );//show the query function dump_request( $query ) { echo “<pre>”; var_dump( … Read more
After several hours of debugging I have found what caused the problem. Custom taxonomy ‘cadassist_category’ is used for 2 custom post types: product_document and cadassist_file. The posts for taxanomy with ID 653 were of cadassis_file type. And I tried to get posts of product_document type. That is why I got empty array. So if you … Read more
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
From the above query, it seems that you have passed wrong parameters in tax_query of your query. It should be as follows: ‘tax_query’ => array( array( ‘taxonomy’ => ‘Themes’, //Your custom taxonomy slug ‘field’ => ‘slug’, // this should be field name, not field value ‘terms’ => array(‘environment’), ‘include_children’ => true, ‘operator’ => ‘IN’ ), … Read more
Post types showing tables…Can I do that?
// 12 – difficulty // destination // get Id current taxonomy $this_term = get_queried_object(); $taxquery = array( ‘posts_per_page’ => 1, ‘post_type’ => ‘packages’, ‘tax_query’ => array( ‘relation’ => ‘AND’, array( ‘taxonomy’ => ‘difficulty’, ‘field’ => ‘id’, ‘terms’ => array( 12 ), ), array( ‘taxonomy’ => ‘destination’, ‘field’ => ‘id’, ‘terms’ => array( $this_term->term_id) // Id … Read more
How should i name the .php file to show custom posts under a taxonomy’s term?