Articles of wp reset query

2 queries with counters

I have 2 loops on a page both containing a counter to implement slightly different code every 6 posts. For some reason though the second loop is implementing the different code sometimes after 4 items instead of 6. Am I not resetting the loop correctly? <ul class=”tabs”> <li class=”tab-link current” data-tab=”tab-1″>Most Popular</li> <li class=”tab-link” data-tab=”tab-2″>Recent</li> […]

3 Posts in Loop, Show Stickies First

Okay I am starting to wonder if it is even possible to do this! As I’ve found very little info on the matter online. This is a fresh WP install that I’ve been experimenting on so that I can work in a more simplified environment (rather than try to solve the full problem itself on […]

RESOLVE – Numeric pagination custom post type

i create a custom page to display loop of cpt with custom field. I need to add a numberic pagination and i try with this code but not work. Functions.php function pagination_bar() { global $wp_query; $total_pages = $wp_query->max_num_pages; if ($total_pages > 1){ $current_page = max(1, get_query_var(‘paged’)); echo paginate_links(array( ‘base’ => get_pagenum_link(1) . ‘%_%’, ‘format’ => […]

Problem with different query loops (and “main loop”) on category template page!

so, heres the problem: i’ve created a category-template (category.php) with two query loops and the main loop (in which the content from the category should get looped in). if i now click on a category the template page shows but also the first two query loops get affected by it. everything is messed up. above […]

WP_Query and is_page_template() conditional

I have a custom query that goes looks like this: $temp = $wp_query; $wp_query = null; $args = array(‘posts_per_page’ => 5, ‘post_type’ => ‘gallery’, ‘post_status’ => ‘published’, ‘paged’ => $paged); $wp_query = new WP_Query($args); if($wp_query->have_posts()): while($wp_query->have_posts()) : $wp_query->the_post(); if(get_post_format()) { $post_format = get_post_format(); } else { $post_format = ‘standard’; } get_template_part(‘/templates/parts/format’, $post_format); endwhile; endif; ?> […]

wp_reset_postdata() and wp_reset_query() inside shortcode are not working to reset original page query

I’m implementing a form for a frontend post with a shortcode. The form is processed in the same function, reloading the page: function adicionar_ninhada(){ $user_id = get_current_user_id(); if (isset($_POST[‘adicionar_cachorro’])){ wp_verify_nonce( $_POST[‘_wpnonce’], ‘brg_add_dog’.$user_id ); $args = array( ‘post_title’ => $_POST[‘raca’] . ” nascidos em ” . $_POST[‘nascimento’] , ‘post_content’ => ”, ‘post_status’ => ‘publish’, ‘post_author’ => […]

WP_Query in functions.php overrides global $post object, even with wp_reset_query()

I’ve written a function that grabs all posts that are drafts and puts them as a dropdown in my toolbar for easy access to complete. This works just fine. The problem is that it seems to mess with my global $post object, specifically when called in my post/page editor. So if I’m in my post […]

When should you use wp_reset_postdata vs wp_reset_query?

Seems like half the tutorials in the Codex use wp_reset_postdata() and half use wp_reset_query(). What’s the deal? Maybe Use both of them? What about rewind_posts()? I am asking for an answer based on facts, not on opinions.

Is it necessary to reset the query after using get_posts()?

Is it necessary to reset the query after using get_posts() ? I have been looking at this page and I don’t see any reference to get_posts() … I can’t make it out for sure from this page either. I can’t see why it wouldn’t be necessary ( though on my test page it doesnt cause […]

wp_reset_postdata() or wp_reset_query() after a custom loop?

Reading some stuff about query_reset_postdata and query_reset_query makes me confused. For example: Is there any need to use both wp_reset_postdata and wp_reset_query together? http://www.poststat.us/properly-reset-wordpress-query/ Above states that you should only use query_reset_postdata() when using “separate queries”. In example2 there’s a comment: WP_Query( $args ) = wp_reset_postdata(); AND query_posts ( $args ) = wp_reset_query(); And really […]