Questions tagged [wp-reset-query]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0 votes
0 answers
10 views

Why am I getting no results of a query placed after another query?

I want to run two queries right after each other. Both queries return posts on their own. When I have both of them after each other, only the first one returns results. I've tried wp_reset_postdata(), ...
0 votes
1 answer
50 views

Is it possible to make is_category() recursive?

In resetting the main query for category pages for a custom post type, I would like to write one test for a parent category and have it test positive for all child categories, recursively. For example,...
0 votes
1 answer
41 views

3 posts from each existing category on one page

The following is not working... <?php $categories = get_categories( array( 'orderby' => 'name', 'parent' => 0 ) ); foreach($categories as $category): $args = array( 'cat' => ...
0 votes
0 answers
89 views

wp_reset_postdata not working

i have this query add_action('edit_form_after_title', 'get_books'); function get_books($main_post){ global $post; $list = ''; // print the current post (everything is still fine here) ...
  • 23
4 votes
1 answer
944 views

Why should i use wp_reset_postdata()?

I am not able to understand the use of wp_reset_postdata. what could go wrong if i am not using it? https://codex.wordpress.org/Function_Reference/wp_reset_postdata Here in documentation what is ...
user avatar
1 vote
1 answer
574 views

Reset postdata to custom query in nested queries

I have a main query, in which I set up a new custom query to retrieve posts (think about 'related posts' or something like that). Than in each of those posts, I'm setting an other custom query, load ...
  • 180
3 votes
1 answer
3k views

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 ...
0 votes
0 answers
36 views

Why does the theme insert the comments section if I don't reset my custom WP_Query?

I have a bit of an odd situation. I have somehow solved it, but I'm trying to understand why my solution works. I'm using TheBuilt, a theme that uses Visual Composer. I have extended Visual Composer ...
0 votes
1 answer
328 views

Populate metabox dropdown with post title from another Custom Post Type (issues with wp_reset / global $post)

I have a custom post type, and in there I have a metabox with a dropdown. The dropdown is populated with the titles of posts from another custom post type. My metabox system works. I tried ...
  • 21
2 votes
3 answers
27k views

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 $...
  • 73
0 votes
1 answer
1k views

how to filter the data's comparison operators (>= & <=) & range between values using the WP REST API

I'm quit new for wordpress development. Working with property management website with mobile API Development. Here need to filter the data's for based on conditions like greater than and less than &...
1 vote
0 answers
1k views

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(...
2 votes
1 answer
804 views

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 ...
  • 159
1 vote
1 answer
1k views

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 ...
user avatar
0 votes
1 answer
139 views

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 ...
0 votes
1 answer
1k views

How to do a loop inside a loop?

I'm trying to get posts from a custom posts using WP_Query. <ul> <?php $query1 = query_posts( array( 'posts_per_page' => -1, 'post_type' => array('specialties') )); if(...
0 votes
1 answer
55 views

Different number of posts showing in development vs production server

So I'm working on a website for a client. Everything works fine except for the fact that the number of posts showing in the homepage of my development server is different from the number of posts ...
  • 837
0 votes
2 answers
239 views

Related post by category throws internal server error

I am using thesis in wordpress 4.1 i am trying to display related post by category with bellow function but when i go to the post detail page it throws internal server error.i have used same code in ...
64 votes
1 answer
82k views

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....
0 votes
2 answers
3k views

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' => '...
-1 votes
1 answer
1k views

Resetting a Query using wp_reset_query() or wp_reset_postdata() does not work

I am using ACF as related posts. I have the following code. <?php $post_objects = get_field('repeater_related_items'); if( $post_objects ): ?> <ul> <?php foreach( $post_objects ...
0 votes
1 answer
65 views

Loop being strainge

So I hacked together a function that does the following: protected function _query_post($query){ $original = $this->_wp_query; $wp_query = new WP_Query($query); if($wp_query->...
  • 1,055
0 votes
1 answer
2k views

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 ...
11 votes
1 answer
10k views

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 ...
  • 3,012