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 queries and pagination
- WP_query paged pagination with excluded category still counts it
- Why doesn’t my WP Meta Query return any results?
- max_num_pages says 4, yet I am only able to navigate to the third page
- Custom Homepage Pagination using WP_Query
- Paginate pages with dynamic query
- filter posts by meta key with pagination
- Determining what post is displayed out of total posts found
- Trouble Making WP_Query paged
- WP_Query meta compare must include ALL array values
- Start Query from 2nd Post without offset
- Adding pagination to sub-wp_query within a singular post page
- Disable (or limit) queries when certain content (or data) is not needed (or showed)
- How to filter a static post page with ajax and $wp_query
- Pagination problem by using WP_Query
- Ajax (jquery) wp_query pagination returns -1
- Display upcoming events in the next 30 days by querying posts with timestamp in custom meta
- WP_Query and pagination AGAIN?
- Prioritising and Ordering Posts By Category Name Using A Custom Loop
- WP_Query Pagination
- meta_query where the meta value is not the post title
- WP_Query, Paginate by Custom Field
- Post incorrectly excluded when using “category__in”?
- Query multiple post types, but different order for each
- Reciving Error 404 blog/page/2/
- Multi-layered WP_Query
- Why is my pagination /page/2 taking me to index.php?
- `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
- Display posts ONLY from the current logged in user and current week/year/month Elementor posts
- adding pagination to a foreach loop in wordpress
- duplicated posts when using pagination
- paginate_links appearing on page but it doesn’t actually paginate – pagination on a static page with a dynamic `post_type` argument on a static page
- wordpress pagination wont render on custom page template even though its right under the loop like the documentation says so
- Query pages created by deleted users
- Is it possible to give a classname to specific comments in the WordPress admin?
- pre_get_posts pagination not working
- How can I have sticky posts while ALSO showing posts from a specific category using one WP_Query?
- Pagination repeating posts on search results
- setting offset to category number in archive page
- Woocommerce Get Orders By Meta Value
- Pagination not working on archive.php template?
- WordPress Sub Category Archive, Show Extra Empty Page Number in Pagination
- WP_query pagination on frontpage
- Any way to use FETCH_KEY_PAIR with $wpdb?
- pre_user_query vs pre_get_posts
- Exclude post from wp_query based on custom field boolean
- How to do WP_User_Query for Nested Array value Inside Nested Array field
- Get posts that match defined arrays of tags
- Doing $wpdb->get_results returns NULL, doing the same query in my DB returns correct value
- Pagination unique to a widget
- Move some posts to end of sort order, even if there is a sort in the wp_Query already
- Adding nofollow to all the post links in get_posts with pre_get_posts or WP_Query
- Meta query orderby meta_value_num sorting by role first
- How to get meta key list efficiently?
- Pagination inside the blog page not working
- Order posts by tags count?
- Pagination for Category does not work
- Query against multiple locations within single custom post type post
- Pagination on archive.php not working?
- paginate_links method doesn’t show second page of my custom wp_query
- Wp_Query Post per page not working?
- Pagination Shows Up But Won’t Work on Custom Gallery Page
- Query Posts | Combining multiple form inputs into query arguments to generate one filter result
- Strange results from WP_Query
- Is there a way to control both Order By and Order query parameters from one input field
- Custom Query Pagination not working on static front page
- How to get_comments() ordered by date and parent?
- I need query_posts() to order results first by a meta value and then by post ID
- WP_Query & Duplicate entries
- How to query 5 users in random who have published more than 10 posts
- How to query users by post count no less than 10
- WP Query. Ordering posts by another post types meta
- Add to search posts query array with post IDS which will appear first
- 404 page on custom search pagination
- WordPress search page pagination displaying but not functional
- return child post if available otherwise parent post
- Search has query that will return no results
- Is my code correct?
- How to make a search query if not found in post table then search in postmeta table?