Get array of posts from the current archive page loop
That’s pretty easy. All you need is this: global $wp_query; $my_posts = $wp_query->posts;
That’s pretty easy. All you need is this: global $wp_query; $my_posts = $wp_query->posts;
You simply don’t need to specify a post_type when calling get_post(). The ID for any sort of post is unique among the whole DB-posts table. So if you’re calling a post with ID = 17 $id = 17; $post = get_post( $id ); then you’ll simply get this single post. Note, according the Codex, when … Read more
You can use current_post within the loop to track where you are and split the loop into multiple parts: while ( have_posts() ) : the_post(); // only output content if it’s post 1 – 5 if( 5 > $wp_query->current_post ): the_title(); else : break; endif; endwhile; // do another query/loop $custom_loop = new WP_Query( $args … Read more
Loosely what you have should work already. However few things are off. Calling these function without time format will produce values like 1:36 pm (depending on your site’s settings), which are not exactly comparable. Post modified time can be less than published in some cases, like scheduled posts. So I would write it along the … Read more
As mentioned in the comments, wc_get_template_part() tries to locate and load the requested template file. These template files could be ether in the /woocommerce/ sub-directory of a child-theme, or defined in another third party plugin (with the help of woocommerce_locate_template filter hook). If none of these exists, WC loads the default template file from /plugins/woocommerce/templates/ … Read more
The argument that controls how many posts are shown in the query is posts_per_page <?php query_posts( array( ‘post_type’ => ‘post’, ‘posts_per_page’ => -1 ) ); ?> Also to note is that there is a bug in the 3.0 branch which prevents the -1 integer from displaying all posts. It is fixed in 3.1 but a … Read more
If i understand correctly you are trying to display a list of child pages of a page in a widget, if so then first check if you are on a page using the conditional tag is_page() then you can use $wp_query->get_queried_object_id() like t31os has pointed out so your widget display function should look like this: … Read more
ok, after some research I came up with the solution. The solution is for displaying wordpress comments outside the loop and as a bonus how to place disqus comments outside the loop as well. First, How to place wordpress comments outside the loop: In single.php we need to define a new global variable for storing … Read more
I’m fairly certain the problem is that some template tags rely on the global $post variable. Using setup_postdata() as you are now, will not alter $post. If you replace all the instances of $pageChild with $post, everything should work. However, I would strongly recommend using the WP_Query class and setting up your post data with … Read more
I had faced the same problem. And finally, I solved the problem. Getting the current Pagination Number <?php $paged = (get_query_var(‘paged’)) ? get_query_var(‘paged’) : 1; ?> For getting the current pagination number on a static front page (Page template) you have to use the ‘page’ query variable. <?php $paged = (get_query_var(‘page’)) ? get_query_var(‘page’) : 1; … Read more