A piece of javascript/jquery:
$("#queryMenu ul li a").click(function(){
var currentCategory = $(this).attr('id');
$.ajax({
type: 'post',
url: 'ajax-category.php', //sometimes I'm using bloginfo to get current path: url: '<?php bloginfo('template_url'); ?>/ajax.php',
data: {
currentCategory: currentCategory
},
success: function(data) {
console.log(data);
}
});
});
Put right path in url. Use $_REQUEST['currentCategory']
inside ajax-category.php to get category ID…
Related Posts:
- Pagination for ajax category filter
- Exclude posts without category from loop
- Remove “?category=” in the URL wordpress ajax filter work for category
- WordPress Post # of # filtered by category slug
- How to hide category name
- Inside a loop, how to change CSS class based on category name?
- Exclude current post from loop
- How to insert category list into post creation page, and retrieve chosen categories?
- Categories list loop – add separator every 3 categories [closed]
- Limit get_categories to show each category once
- Display single category name in woocommerce loop
- Show Posts from Single Category Not Working
- How to make the ‘delete’ button inactive on some categories?
- Is there a reason I cannot get the current category in a loop?
- Category archive is displaying all posts rather than the specific category
- Pagination on category.php and tag.php not working
- new WP_Query all post in a category inside the loop
- Trying to get variables in hacked category dropdown
- Problem with different query loops (and “main loop”) on category template page!
- How to do paging in the loop?
- How to add orderby parameter for sorting on category.php
- category__not_in and id values from variable
- Overriding default calendar to show posts from a category
- How to loop custom post_type from (a) specific category(ies)?
- How can I display tags as categories?
- Do not show sub categories in the loop on archive-product.php
- How to display the parent category if only the child category has been chosen
- Display all product tags associated with a specific product category
- Category tags with comma’s
- Display posts of certain categories to specific user roles
- Filter WooCommerce archive pages by an additional category
- Portfolio Filter Buttons Wont Work
- Allow user to select categories that will display in post loop
- Filter posts by categories ajax is showing nothing
- Insert HTML content in WP Query at specific point
- “Virtual category page” based on a custom field filter
- Custom tax_query filter not working for Woocommerce product categories
- Simple way to style posts of a single category differently in the loop and in single
- Remove any product that is featured from regular display loop [WooCommerce]
- Two Sections on Woocommerce Catergory Page [closed]
- How to hide some categories in dashboard
- Getting the Most Recent Posts from Multiple Categories
- Change post title if post has specific category
- Filter By Category Dropdown List With Custom Taxonomies
- Display subcategories in dropdown
- Display category title and three latest post inside the category
- More efficient way to list posts by category [duplicate]
- Have posts that belong to multiple categories, exclude some categories from homepage
- Category nicename inside loop in wordpress
- Show multiple categories in query using redux framework variable
- Get the ID of the current post’s child category
- filter a loop base on specific category
- Problem with multiple loops in wordpress theme
- multiple values in an array for category__and does not work with WP_Query
- How can I filter posts by tag on the fly
- Limit Loop to One Category
- Display post thumbnail for specific category outside the loop
- List post only under the category, exclude child category content
- Filter Category Loop Dynamically
- How can I use AJAX with check-box categories?
- Editing Loop So It Targets Specific Tags?
- Change Default Content when Creating a Post based on Previous Category Choice
- the_category() doesn’t working in wp_query loop
- Conditional category query breaking?
- Problem: retrieving parent category’s first post
- Maintaining a separate posts page for certain categories and don’t show those on home page
- How to get posts using category slug in ClassiPress?
- Category sticky latest
- Get current taxonomy and display query accordingly
- Posts made to category don’t show up (do show up on frontpage)
- How to filter post from categories only if the posts appears in one of them, not the other?
- Category name for all posts getting assigned to a single random post
- Category post count is not correct
- Display all categories but only if they have posts in them that have a specific tag assigned
- How to fix select filter on category
- wp_dropdown_categories() works correctly but the list is not filtered in admin for custom post type. What is the problem?
- Include last post date in get_categories loop
- Show the number of the post
- Loop order issue with Ajax filter
- Add $args to wp_list_categories
- How to hide a category or tag everywhere EXCEPT for use with get_posts
- Add filter for specific category only
- How to create category filter on a blog like on the site below?
- How can I order all subcategories alphabetical independent of the parent categories?
- How to get specific (grand parent) category of current post?
- How to filter tags by category?
- Custom Loop with certain number of one category
- how tho change number of posts in loop from specific categories
- Custom Taxonomy Isotope Grid – Filter Buttons Not Working
- How to exclude a category returned by get_categories from function.php?
- Template category.php with page (no posts)
- Can’t display posts by filtering categories using isotope.js
- how can I edit the HTML of yith ajax product filter
- how to filter posts by category without page load (ajax) in wordpress?
- error in specific category loop
- loop in single.php of the same category
- Correct Hook/Filter to amend category choices on post edit page
- Restrict retrieved terms by category?
- WordPress Ajax filter: Create two loops for different output styles?
- How to create a category loop on my blog (ACF Plugin)