I’m not sure this will fix it, but maybe try using the current category slug for the $current_category
variable, instead of single_cat_title()
, like so:
$term = get_queried_object();
$current_category = $term->slug;
This might help because the category_name
parameter in WP_Query, despite its name, should be the term slug. single_cat_title(
) returns the displayed category title, not slug.
Related Posts:
- Add and in the header while looping over custom query in page template
- Overwrite YoastSEO meta-tags with another page’s [closed]
- Custom WP_Query order by post_meta and (author) user_meta
- Transient pagination not working properly
- How to output different posts per page?
- Create ONE callback for all page templates, post filter queries + paginated pages, triggering pagination via AJAX
- Multisite pagination issue by multi query archive 404
- Notice thrown when creating numeric pagination on custom query
- WP_Query custom order and pagination
- Unable to paginate a custom page query
- I am officially missing something about transient posts
- Pagination of custom page with custom fields query
- Why pagination is not working with tax_query param?
- Custom pagination (Title, date and teaser)
- Pagination is not working on custom query inside a custom home page template
- Pagination in custom query in a category page
- Horizontally paginate through sets of blog posts?
- Pagination in WP query with transient API
- Search results stuck on page 1
- Multiple WP_Query loops with Pagination
- paginate_links() adds empty href to first page and previous link
- What is the most efficient way of querying posts based on visits and date for current day?
- WP_Query and Pagination on a Static front page
- Pagination custom query
- Pagination/infinite scroll with WP_Query and multiple loops
- Order posts by tags count?
- Which custom query am I in and how can I access its properties & methods?
- Pagination not working on static page
- ‘paged’ in wp_query doesn’t work
- Display different number of posts from one category on the different pages
- Pagination not working Search posts
- WP Query with offset breaks wp_pagenavi or any pagination
- How to speed up wp_query, took more 5s to run against 100k posts
- WordPress pagination link always leads to home page
- How do you query wordpress posts using a math formula between multiple meta field values?
- Undefined WP_Query::has_posts()?
- Is it possible to dynamically get queried term AND taxonomy?
- Pull post meta with post_query?
- Minimize database queries to user tables?
- Should $found_posts be returned as string in ‘found_posts’ filter hook?
- Pagination of a WP_Query Loop in a child-page page template
- Query all published post AND attachment with specific mime type
- Get all products which have both product category
- unable to retrive parent page information
- wp_query ‘s’, search filter with pagination is not working
- How to display user order by role
- WP Query related posts by tags
- Order by summing multiple values
- Order by empty custom field
- Check if loop has any categories?
- Avoid repeated post on page 2 when excluding one on page 1
- No results found from a $wpdb->get_results() query when trying to join more than one meta key query
- Query only the posts with a post format of “audio”
- pre_get_posts – Trying to get property of non-object warning
- WordPress query posts with multiple post_meta data
- Include latest author posts with pagination in single template?
- Is it possible to retrieve posts depending on meta_key LIKE condition? [duplicate]
- Pagination in html table is not working
- Write WP Query that selects posts that are part of the same two categories
- WP_User_Query orderby meta_val_num
- Include one page/post into query which is already returning posts
- Query Not working as expected
- WP_query paged pagination with excluded category still counts it
- Why doesn’t my WP Meta Query return any results?
- Determining what post is displayed out of total posts found
- Disable (or limit) queries when certain content (or data) is not needed (or showed)
- Prioritising and Ordering Posts By Category Name Using A Custom Loop
- Filter products on category AND tag
- WordPress Sub Category Archive, Show Extra Empty Page Number in Pagination
- Exclude post from wp_query based on custom field boolean
- Doing $wpdb->get_results returns NULL, doing the same query in my DB returns correct value
- Pagination unique to a widget
- How to get meta key list efficiently?
- paginate_links method doesn’t show second page of my custom wp_query
- Wp_Query Post per page not working?
- I need query_posts() to order results first by a meta value and then by post ID
- WP_Query & Duplicate entries
- Query by meta value (add a dropdown of all values)
- Combine WP_Query with array of custom data to single loop without breaking the pagination
- orderby in WP_QUERY – Use the order from the Dashboard
- Random posts in WP_Query when searching by tag
- Query posts in current category but not attachment format
- WP_Query with Pagination and orderby meta_value_num showing duplicates
- wp_query – Modify $query to include duplicate content
- Optimising specific Query with ACF meta objects
- How to get several fields from wp_query?
- Combine privileged users array with my current query
- Pagination not working with WP_Query (creates links but no page)
- Query custom post type by date field only working when two posts match the query
- meta_query dates from an array
- Divide WP_Query posts by date & post type
- Query Posts by date range with fixed beginning and end
- query by meta value then date and not empty meta value
- New WordPress WP Query using posts from certain categories
- Query specific number of posts for each post type in specific order
- WordPress Post Looping? [duplicate]
- error with $query->have_posts()
- Use value from meta key array for use in WP_Query
- Pagination only showed when no category is set in wp_query
- taxonomy-{term}.php terms pagination returning 404 after a certain page