Display posts between two particular dates

I think its because the SQL statement needs the dates inside the quotation marks. Try $where .= ” AND post_date >= ‘$s’ AND post_date <= ‘$e'”; That should work, otherwise, try $where .= ” AND post_date >= ‘”.$s.”‘ AND post_date <= ‘”.$e.”‘”;

Query does not return content

You shouldn’t be using query_posts() here, but rather WP_Query(). (Search WPSE for query_posts if you want to know wy.) <?php $custom_query_args = array( ‘post_type’ => ‘page’, ‘post_parent’ => ’50’, ‘post_status’ => ‘publish’, ‘orderby’ => ‘menu_order’, ‘order’ => ‘ASC’, ‘posts_per_page’ => ‘100’ ); $custom_query = new WP_Query( $custom_query_args ); // To see the contents of the … Read more

Restrict query to last day with posts

You need to find the most recent date with posts and use that to construct the $current_ fields. $last_date = $wpdb->get_var(“SELECT DATE(MAX(post_date)) FROM {$wpdb->posts} LIMIT 1”); if (!empty($last_date)) { list($current_year,$current_month,$current_day) = explode(‘-‘,$last_date); query_posts( “cat=5&year=$current_year&monthnum=$current_month&day=$current_day&order=ASC” ); }

Custom SQL Query passing array to WHERE p.id

This is more of a SQL question then a WordPress question. Here are some ideas: You’re most likely looking for this kind of structure: AND p.ID NOT IN (1433, 1344) You should consider using $wp->prepare() if your query depends on some user input. You might also want to replace CURDATE() with a PHP generated date … Read more

get_posts showing only 5 posts. (nopaging and posts_per_page -1 not working)

The ‘posts_per_page’ => -1, and ‘nopaging’ => true, shouldn’t be in your tax_query params. That might be what’s throwing it off. Try: $args = array( ‘post_type’=>’gpp_prod’, ‘orderby’ => ‘title’, ‘order’ => ‘ASC’, ‘posts_per_page’ => -1, ‘nopaging’ => true, ); and: $args[‘tax_query’] = array( array( ‘taxonomy’ => ‘cat_prod’, ‘field’ => ‘term_id’, ‘terms’ => $category ) );

How to reset usual $query on search page to push custom $wpdb query there?

This is not how pre_get_posts works. The pre_get_posts action gives developers access to the $query object by reference (any changes you make to $query are made directly to the original object – no return value is necessary). https://codex.wordpress.org/Plugin_API/Action_Reference/pre_get_posts What you are doing is simply wrong. You don’t “return” another query via pre_get_posts, you alter the … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)