Get all posts which was posted on X Days WordPress

You can try following code $y = date(‘Y’); $m = date(‘m’); $d = date(‘d’,strtotime(“-7 days”)); //Date you want $args = array( ‘posts_per_page’ => -1, ‘post_type’ => ‘post’, ‘date_query’ => array( array( ‘year’ => $y, ‘month’ => $m, ‘day’ => $d, ), ), ); $posts= new WP_Query( $args ); //you will get posts which are posted … Read more

Counting Search results, and displaying the offset per page

I’m afraid you’re doing it a little bit wrong… Here are the problems: post_count field contains the number of posts being displayed and not the offset. wp_count_posts returns the number of posts globally, not in current query (so it will not be true for queries that have some filters). echo $post_count; . ‘-‘ . $post_count; … Read more

Always using the same ARRAY on different querys

I don’t like using categories for this, as they are supposed to be semantic terms. I do, however, like the idea of the global array. Instead of creating a new query directly, I will filter it through a function that will add the results to a global array and return the results: I add this … Read more

How to list posts from a plugin taxonomy?

To query by taxonomy you need to know its query_var that is used in its register_taxonomy() call. It defaults to taxonomy name so usually equal to that. Then you use that info in query argument: query_posts( array( ‘query_var’ => ‘term’ ) ); See Querying by taxonomy in Codex. It is hard to suggest more without … Read more

How to Query Post

Try this: <ul> <?php global $post; $args = array( ‘numberposts’ => 5, ‘category’ => 1 ); $myposts = get_posts( $args ); foreach( $myposts as $post ) : setup_postdata($post); ?> <li><a href=”https://wordpress.stackexchange.com/questions/12234/<?php the_permalink(); ?>”><?php the_title(); ?></a> – <?php the_date(); ?></li> <?php endforeach; ?> </ul> More info: query_posts()