WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I've been looking around for a way to filter my posts on http://www.waziproject.com/wazimagazine/ without reloading the page.

So my question is if anyone can help me out to turn the following into a list of filters that don't require refresh/reload of the page...

I believe the following answer is the closest I can get to a solution: Using ajax on categories and wordpress loops

However, I'm not sure where to implement the code. I'm using the following in my loop.php:

<div id="queryMenu">
    <li><a href="#" id="business_work">Business & Work</a></li>
    <li><a href="#" id="development_sustainability">Development & Sustainability</a></li>
    <li><a href="#" id="education">Education</a></li>
    <li><a href="#" id="health_medecine">Health & Medecine</a></li>
    <li><a href="#" id="human_rights">Human Rights</a></li>
    <li><a href="#" id="law_order">Law & Order</a></li>
    <li><a href="#" id="media_information">Media & Information</a></li>
    <li><a href="#" id="nations">Nations</a></li>
    <li><a href="#" id="political_economy">Political Economy</a></li>
    <li><a href="#" id="research_innovation">Research & Innovation</a></li>
    <li><a href="#" id="reset">All Posts</a></li>

Now if I want to apply the coding as mentioned here - Using ajax on categories and wordpress loops - where should I put the different code snippets and is there a lot of tweaking to be done to it?

Thank you very much in advance for your help!

share|improve this question

A piece of javascript/jquery:

$("#queryMenu ul li a").click(function(){
    var currentCategory = $(this).attr('id');
        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) {

Put right path in url. Use $_REQUEST['currentCategory'] inside ajax-category.php to get category ID...

share|improve this answer
Your selector is not efficiently.jquery is trying to find right to left. a - li - ul..... – ahmetlutfu Apr 5 '14 at 20:44

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.