Query posts using less than

How about something like this? $args = array( ‘date_query’ => array( array( ‘before’ => array( ‘year’ => 2013, ‘month’ => 2, ‘day’ => 28, ), ‘inclusive’ => true, ), ), ‘posts_per_page’ => -1, ); $query = new WP_Query( $args ); Obviously you could set the exact date from a variable. More info: https://codex.wordpress.org/Class_Reference/WP_Query

WP_Query multiple post results

Your loop is wrong, you should not use to foreach inside the while, simply add the classic the_post () using the variable of your loop in this case $ loop for example <?php $args = array( ‘post_type’ => ‘product’, ‘stock’ => 1, ‘posts_per_page’ => 9, ‘product_cat’ => $pagename, ); $loop = new WP_Query( $args ); … Read more

How to remove only the latest sticky post from the loop

So if you’re getting the sticky-post you want removed anyways I want to do that coz I will make another query to render the latest sticky post on top of the main loop in a separate ‘div’ Just make a variable, $excludeSticky, with it’s ID, and add an ‘post__not_in’ => array($excludeSticky), argument in your query.

Custom post type and custom taxonomy 404 on page 2

So after many trials and errors, I found I had to create a specific rewrite rule to go into my functions.php, one that handles post type ‘videos‘ and the category (taxonomy) ‘videos_category‘: add_filter(‘init’, function() { add_rewrite_rule( ‘^videos/([^/]*)/([^/]*)/(\d*)?’, ‘index.php?videos_category=$matches[1]&p=$matches[2]&paged=$matches[3]’, ‘top’ ); }); I also found this plugin to be really helpful for viewing my rewrite rules: … Read more

Multiple wp_query on archive page

I’m not entirely sure, but it looks like you need another conditional in your filter. Right now, it filters all content looking for category, tag or date that don’t have the nav_menu_item, mvp_projecvts query variable set for post types. Perhaps you could add a filter to check if some variable is set and only filter … Read more

Wpdb->query result show 1 but is not an integer

I found the solution. The result 1 for my query means true and it’s a boolean so $wpdb->query can return true, not only int|false as it is written above the public function query : wpdb::query PHP code $res = $wpdb->query(“ALTER TABLE ” . $table_name. ” ADD ” . $column_name . ” varchar(35)”); error_log( $res ); … Read more