return wp query results in a shortcode
return wp query results in a shortcode
return wp query results in a shortcode
Looks like all I needed was to include ‘posts_per_page’ => -1 in the $query_args array. Final, working code: <ul class=”tag-list”> <?php $query_args = array( // Easier to call the parent category, “recipe” instead of dealing with all these ids // ‘cat’ => ‘101,94,93,56,72,99,100,63,98,95,96,80,4’, // Calling recipes (4) and ingredients (56) category ids – specific recipe … Read more
After giving it another look with some fresh eyes, I decided to add a third loop within Loop 2 and not have it working as desired: $media_args = array( ‘post_type’ => ‘attachment’, ‘posts_per_page’ => -1, ‘tax_query’ => array( array( ‘taxonomy’ => ‘products’, ‘field’ => ‘term_id’, ‘terms’ => $product_tag ) ) ); // Loop 1 – … Read more
Query stopped working
Switching out echo get_comments_number($post->ID) for echo $post->comment_count did the trick. I have no idea why, that’s exactly what the get_comments_number() function does…
You need a loop within a loop – loop through a counter, and for each value, check for the existence of each key with the current counter value appended. // max custom field index $number = 40; // the counter $counter=””; // the meta keys to check for $keys = array( ‘custom_text’, ‘custom_image’, ‘custom_video’ ); … Read more
Overwriting auto-appended NOT IN query in WP_Query
I ended up doing this – works perfectly. <?php $argsb = array(‘posts_per_page’ => -1, ‘post_status’ => ‘publish’);?> <?php $blog = new WP_Query($argsb); if ( $blog->have_posts() ): ?> <section class=”blog-slider slider”> <div class=”flexslider”> <ul class=”slides”> <?php while ( $blog->have_posts() ) : $blog->the_post(); $i++;?> <?php if( $blog->current_post % 3 == 0 ) echo “\n”.'<li class=”slide”>’.”\n”; ?> <article … Read more
As @Milo said in his comment above, you need to use concatenation as this is a loop your in. So you need to add a value each iteration not replace it. Your $output=”” needs to become $output .= ”. Notice the point/dot before declaring the value, in PHP this is used for concatenation. //the loop … Read more
When you set up your query, do it this way ( I believe you were missing the ‘date_query’ key ): $args = array( ‘date_query’ => array( array( ‘year’ => 2012, ‘month’ => 12, ‘day’ => 12, ), ), ‘ignore_sticky_posts’ => true, ‘post__not_in’ => get_option(‘sticky_posts’) … ); $query = new WP_Query( $args ); http://codex.wordpress.org/Class_Reference/WP_Query#Date_Parameters