Reset Popular post query?

If you’re ok resetting it weekly – as in have views start from 0 every Monday – rather than trying to show the most read in the last 7 days, then the simplest change would be to have a different meta key for every week of the year. Then when you query the posts, you … Read more

How to query custom post types posts filtered by multiple custom taxonomies through a form selection

Apparently the problem was in the “AND” relation. Code now seems to work: <?php if(isset($_REQUEST[‘submit’])) { $prodotto = $_POST[“prodotto”]; $livello = $_POST[“livello”]; $ruolo = $_POST[“ruolo”]; $stato = $_POST[“stato”]; $args = array( ‘post_type’ => ‘corsi’, ‘posts_per_page’ => -1, ‘orderby’ => ‘title’, ‘order’ => ‘ASC’, ‘tax_query’ => array( array( ‘taxonomy’ => ‘prodotto’, ‘field’ => ‘slug’, ‘terms’ => … Read more

Show Only Posts Owned By Logged In User + my post

First, I second Q Studio comment: check Tom McFarlin’s post with a warning about using pre_get_posts. More specifically, pre_get_posts works everywhere, including RSS and dashboard, and you might want to exclude your logic from such places. That said, if I understood correctly what you are trying to do, you can achieve it by using author__in … Read more

Query with a meta value inside a given range

In this situation you will want to use the meta_query parameter, an example: $args = array( ‘post_type’ => ‘page’, ‘post_status’ => ‘publish’, ‘meta_query’ => array( array( ‘key’ => $key, ‘value’ => array($min, $max), ‘compare’ => ‘BETWEEN’, ), ), ); $query = new WP_Query( $args ); The possible values for for the ‘compare’ key are: “=” … Read more

How can i display the posts per week in a particular month?

You’ll need to add a condition to the posts_where filter in wordpress. I have an example here for only pulling posts that are from the current post’s date and earlier: Add this to functions.php // filter wp_query when $dated_before is set function dg_dated_before($where) { global $wp_query, $wpdb, $dated_before; if (isset($dated_before)): $where = $where . ” … Read more

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