wp_list_categories()
is a simple function that returns (or echos, depending on parameter) a list of links to category archives. It needs not to be reset.
When you create a new instance of the WP_Query
class you need to reset postdata, because Template Tags otherwise use that query and not the main query.
You’ve said:
I’m using two of these queries (with different category include strings)…
I am assuming, the “category include strings” are the only difference in the two queries?!
In the second time you’re using this snippet, the variables $cat_left
and $cat_right
are the actual culprits. They do not get overwritten, the new values are added to the end of the array.
Rename them to $cat_left_2
and $cat_right_2
the second time around or set them to NULL
inbetween:
// first list here
$cat_left = NULL;
$cat_right = NULL;
// second list here
Related Posts:
- How to query only for products with status “in stock” in WooCommerce? [closed]
- get_posts with multiple categories
- ajax category filter
- How to filter by category in REST API, excluding posts also in other category term?
- How to order category.php loop by ‘meta_value’?
- How can I display recent posts from a particular category in my header?
- Sorting Posts by custom field
- How to change a custom query into a standard loop?
- WP Query with multiple categories – passing an array works?
- wp_query display posts from same category of the post
- How to show only one post for each categories of taxonomy of custom post that contains a specific custom field
- WP_query category__in not working, only pulls from first category
- WP_Query order by date in meta_value
- How get posts from a subcategory of a category by name?
- get complex results set according to category structure
- Searching through different categories on different pages code is not working
- Get image of latest post from taxonomies/categories
- How To Remove/hide some specific categories from two different categories widget from sidebar
- How to select posts from one category but exclude posts in another category?
- Get Category Archive Template Name Dynamically
- WP_Query arguments to fetch custom post type posts which are in certain category?
- How to get count of posts assigned to given category?
- How to show subcategories using loop?
- List of the years with posts presented
- Remove a specific category ID from related post
- Complex Category selection as per user input
- Show all post for a given category
- Five posts from a category in footer
- How to get all unique categories for posts in loop?
- Display Featured Post by Categories and Avoid duplicated posts
- Cluster WooCommerce products in each Category Archive by Tags assigned to products
- Category applied to pages, creates multiple breadcrumb entries after a search query (On the translated site)
- category query for pages not working
- Can we return all category (not post) with Custom Query Filter? [closed]
- Query posts intersecting tags and categories
- Search Query for multiple categories using ‘OR’ but having certain categories be ‘AND’
- Check if loop has any categories?
- Exclude Category filter from Portfolio section
- Inserting HTML to close and open divs in WP_Query loops
- Category ‘pad_counts’ & ‘parent’ conflict
- Finding WordPress Posts assigned to multiple categories
- Include posts from some categories while excluding from others
- Combine results of multiple WP_Query to resemble single WP_Query
- WordPress Custom Search Form Displaying Unexpected Results
- wp_query is showing posts from other categories
- Hide products in uncategorized category from search results
- How to echo woocommerce category name
- How to display a list of posts in same child category as current post
- Slider won’t work with custom query
- WP_Query with one category in args shows other categories
- How to exclude a category name from showing?
- Loop categories by recent post
- How order posts from category by date and comment count?
- How to get posts by category and by choosing a taxonomy term?
- Getting the permalink to the latest post from a category
- What is wrong with my WP_Query Arguments?
- Widgets: Show Recent Posts Only if the Posts Have Both Categories X and Y
- get_the_terms has strange result since version 6.0
- Related posts by current posts child category
- Filter sub-category from checkbox form
- `offset` WP_Query argument dont work via `pre_get_posts`
- Function the_posts_pagination() not compatible with WP_Query arguments
- Filter products on category AND tag
- adding pagination to a foreach loop in wordpress
- How can I have sticky posts while ALSO showing posts from a specific category using one WP_Query?
- How to use the Term Object from a custom select field in a query
- 3 posts from each existing category on one page
- How to display the category dropdown auto search list when key press?
- Get categories within specific term
- Related categories order posts by category
- How to show specify category template for both parent and child category
- Display All Top Child Categories / Taxonomy
- Query post by Category and custom file (ACF)
- Check the product in the cart from which category is and show message
- Display 3 levels of categories on page
- Filtering ‘Featured’ posts from a batch of category IDs
- Show posts from categories instead of tags
- Multiple values in WP_Query : category__and
- How to exclude posts by ID within a category/archive loop
- I have 3 categories, i want to display on a loop the last 3 of every category
- Adding Category in WP_Query Not Working
- display all posts from category with and without terms in chronological order
- Help displaying related categories
- Pull posts from all categories if quantity is not met?
- how to avoid reloading/refresh the page when displaying the post of wp_list_categories
- Show full category tree for a year with all post titles?
- Retrieving category pages from subcategory returns empty sets
- query.php – multiple is_category functions
- Display Count of posts
- Create multiple sections for all categories and then queries all the posts for each of those categories
- query_posts problem – need help
- Related posts with WP_Query
- Filter posts by category
- query_vars category_name only display one catgory out of multiple categories
- List categories using WP_Query
- Advanced Search – Is this possible?
- How to get post taxonomy url and name in wp_query
- Pagination only showed when no category is set in wp_query
- Using WP Query, I want to include all posts in category 1 as long as they are not also in category 2
- Excluding a category from frontpage but not from WP_Query