Iterate through ID’s in loop
You can access the current post ID within the loop via get_the_ID() while ( $secondary_loop->have_posts() ) : $secondary_loop->the_post(); rating( get_the_ID() ); endwhile; wp_reset_postdata();
You can access the current post ID within the loop via get_the_ID() while ( $secondary_loop->have_posts() ) : $secondary_loop->the_post(); rating( get_the_ID() ); endwhile; wp_reset_postdata();
Custom query with ‘tax_query’ and ‘meta_key’ returning no results
I formed this query based on this answer. I would appear this is no longer the way to do it… I reformatted the query to look like this: query_posts( array( ‘post_type’ => ‘events’, ‘showposts’ => -1, ‘order’ => ‘ASC’, ‘orderby’ => ‘meta_value_num’, ‘meta_query’ => array( ‘relation’ => ‘OR’, array( ‘key’ => ‘_ecmb_datetime’, ‘value’ => strtotime(‘today … Read more
Problem solved, I’ve used this: $d=new WP_Query( array( ‘category__in’ => array(4), ‘post_type’ => ‘post’, ‘posts_per_page’ => ‘-1’, ‘orderby’ => ‘meta_value’, ‘order’ => ‘ASC’, ‘meta_query’ => array( ‘relation’ => ‘AND’, array( ‘key’ => ‘data’, ‘value’ => $t, ‘compare’ => ‘<=’ ), array( ‘key’ => ‘data’, ‘value’ => $o, ‘compare’ => ‘>=’ ) ), ) ); Instead … Read more
I don’t know why have you put $b%4==1 condition. You can simply check for $b==1.And one more thing I would suggest is to use if and else both.So code would be something like this: <?php $b=1; $args = array( ‘tax_query’ => array( array( ‘taxonomy’ => ‘gens’, ‘field’ => ‘slug’, ‘terms’ => ‘newsgen’ ) ), ‘post_type’=>”, … Read more
Custom Post ‘Post Per Page’ Crashing Page?
I need value of saved meta to display next to the post it is associated with
Thanks karpstrucking, This was a simple case of me needing to understand the Query better. Once I fully understood that wp_query returns a string for the sql query, it was a simply case of doing what I needed to do to correction the event_date value, concatenating on the additional title or meta_num_value and returning that. … Read more
In general this would make sense at pre_get_posts since you could just express conditions as meta query and let WP figure out SQL. In your specific case this won’t work, since that format is horrible for programmatic comparison. Unless you can change format to something more friendly, you will probably have to write some pretty … Read more
From the url you supplied it looks like you are using a custom post type of blog. The most likely reasons you are not seeing the post you want to display is that by default WP_Query is only set to display posts – see WordPress Codex on WP_Query Post & Page Parameters for more info. … Read more