Only display post if published in last 24 hours?

As birgire said date query is an array of arrays May be this solves your problemo. $args = array( ‘post_type’ => ‘surf_reports’, ‘posts_per_page’ => ‘1’, ‘category_name’ => $cat (this is pulled dynamically in my template), ‘date_query’ => array( array( ‘after’ => ’24 hours ago’ ) ) );

How to alter local query, not main query [duplicate]

One of the easier ways to do this is to just add the filter before your query and remove it after: add_filter( ‘posts_orderby’, ‘filter_function’ ); $something = new WP_Query( $args ); remove_filter( ‘posts_orderby’, ‘filter_function’ ); Then you can just add your function into functions.php as normal: /** * The below function filters something * Added … Read more

How to show more post at a given category?

put this code in functions.php : function change_numberposts( $query ) { // Only modify the main query if( $query->is_main_query() ){ // Home page if ( $query->is_home() ) { $query->set( ‘posts_per_page’, 6 ); } // Category 21 if ( $query->is_category( 21 ) ) { // parameter for is_category may be Category ID, Category Title, Category Slug … Read more

WP_Query – Object manipulation vs WordPress functions

All 3 of these could do the same thing, it’s just a matter of how you want to use them. the_title() calls get_the_title() which gets the title by $post->post_title. View the_title() Source on Trac View get_the_title() Source on Trac Personally, I would never use choice 3 as from a readability stand point it’s not the … Read more

meta_compare not comparing whole integer

You could try this instead: $bc_args = array( ‘post_type’ => ‘data’, ‘data-category’ =>’insurance-rate’, ‘order’ => ‘DESC’, ‘orderby’ => ‘meta_value_num’, ‘meta_query’ => array( array( ‘key’ => ‘interest_rate’, ‘value’ => (int) $i_rate, ‘type’ => ‘numeric’, ‘compare’ => ‘>=’ ), ) ); $sortedPosts = new WP_Query( $bc_args ); where we use the numeric type. You should also consider … Read more