- This topic is empty.
January 3, 2011 at 3:49 pm #31138
I was hoping for some advice on the best way to go about using tabs within WordPress.
I have 4 categories which I’d like to separate using tabs, but if I use tabs I’m afraid that it will slow the page load down as all 4 loops would have to load in their respective posts within each tab. The first tab is ‘All’ and then the following 3 are categories, but essentially each post would be loaded once by the ‘All’ loop and then again in each category before the page fully loads.
Would it be a better idea to use 1 loop along with an if statement which has a variable that is changed onclick by each tab, when each tab is pressed it changes the variable which changes the category within ‘query_posts’ and reruns the loop. The first option would be easier to set up but I’m worried about load time once the number of posts gets high.
Anyone got any suggestions/advice? Or just their 2 cents. To give you an idea of what I’m trying to achieve please check out the Fantasy Interactive site here: http://www.f-i.com/work If you click on ‘Sort our work’ on the top of the middle column then you get the gist of it.
Many thanks in advance.January 3, 2011 at 4:30 pm #67688
So after a little research I realized that I can’t rerun the loop with a JS variable without refreshing the page, so that option is out. Would using AJAX to bypass a page refresh and save on initial page load work in this situation?January 3, 2011 at 7:27 pm #67657noahgelmanParticipant
You most certainly can run a loop again without refreshing a pageJanuary 4, 2011 at 4:12 am #67670clokey2kParticipant
Maybe you could adapt this to your cause: https://css-tricks.com/examples/FilteringBlocks/
Load all of the posts in one loop, then filter based on category?January 4, 2011 at 12:17 pm #67528
Hey guys thanks for the feedback.
@clokey2k, thanks for that link, looks like a great solution, I’m going to try that out using the tag names within each post’s post_class to categorize them.
Thanks again for the replies!
- The forum ‘Other’ is closed to new topics and replies.