Random loop with code to prevent duplicate output returns no output at all from time to time

The problem is how you’re doing the exclusion. It’s happening after you’ve grabbed your second quote. If it matches the first quote, it just silently fails to appear. Try this for your 2nd block: <blockquote class=”container” style=”color:#1f8665;”> <?php $args = array( ‘post_type’ => ‘quotes’, ‘thesections’ => ‘yoga’, ‘posts_per_page’ => 1, ‘post__not_in’ => array( $do_not_duplicate ), … Read more

Display multiple custom post types and sort them chronological by one of their fields

There is no output for this sample code because the IF statement you used will never return true, since the string ‘post_type’ will never be equal to any other string but ‘post_type’. Use get_post_type(): if ( get_post_type() == ‘eventtype1’ ) { To order by a date custom field, you will need to use the same … Read more

Sticky posts are not showing at the top of category posts

I don’t have direct experience with this, but from what I read… Sticky posts don’t show up by default on category pages, so adding the categories may throw the query into an “I don’t care about sticky posts” mode. You could try running a query first that just grabs the sticky posts, using arguments like … Read more

Alternative to query->set that appends conditions instead of overriding

$query->set isn’t the only method. What you want is $query->get. Using get you can retrieve your existing value, append the additional part you wanted, then set the query variable with the new argument $tax_query = $query->get( ‘tax_query’ ); // add the extra parameter $query->set( ‘tax_query’, $tax_query ); The adding the extra parameter is just appending … Read more

$wpdb select date range of posts

You basically have the answer, just add $date2 to the inner sql where clause: AND p.post_date > ‘$date2’ to get last week. To get a particular week, use AND p.post_date < ‘$date1’ AND p.post_date > ‘$date2’ where eg $date1 = date(‘Y-m-d’, strtotime(‘2014-07-04 +1 days’)); $date2 = date(‘Y-m-d’, strtotime(‘2014-07-04 -8 days’)); To return weekly/total votes, you … Read more