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?
Leave a Reply
You must be logged in to post a comment.
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.