I want my index.php to be a simple page with a horizontal list of category names on the top. But instead of having the page reload with the list of posts in that loop each time a category is clicked on, I want the set of posts from each category to display instantaneously after every click on a different category. Is this possible in Wordpress?
Yes this is possible with WordPress but I would not use index.php but a custom front-page.php template then create a page called home and set it as the front page in options-general.
For your category menu:
Where calling our jQuery ajax function when a category is clicked and passing the cat ID to jQuery in the name of the function.
The html div place holder where your posts will load via ajax:
The jQuery function called via the onclick handler in the menu items:
The WordPress PHP function to return the posts from the category selected.
We are using output buffering which helps prevent the function from failing which can happen sometimes with WordPress Ajax.
protected by kaiser Mar 12 at 13:01
This question is protected to prevent "thanks!", "me too!", or spam answers by new users. To answer it, you must have earned at least 10 reputation on this site.