Jump to content
Sign in to follow this  
zouleo

Page with custom query_posts() - how do I do it?

Recommended Posts

zouleo

I need a page with a custom query_posts(). I understand that the usual loop of posts is done in this file template.postloop.php Should I just make a copy of template.postloop.php, change the query_post() part, rename it and put it the platformbase directory? Or is it possible to make a new blank page template that includes the template.postloop.php code? Please advise.

Share this post


Link to post
Share on other sites
Rob
Probably best to try copying template.postloop.php to platformbase. If it doesn't work, you can always delete it with no damage done.

Former PageLines Moderator, Food Expert and Raconteur

Share this post


Link to post
Share on other sites
zouleo
I'd prefer not copying template.postloop.php - because you might want to make changes in that file in the future, and then I will still be with the old copied file... Is it possible to include the template.postloop.php and only change the query used?

Share this post


Link to post
Share on other sites
Rob
Actually, if you have it in the base section, it will remain intact. Your suggestion of changing the query in PlatformPro (not the base) would ensure that a future upgrade would undo your work. My suggestion protects it. Please give it a try if you wish your solution implemented.

Former PageLines Moderator, Food Expert and Raconteur

Share this post


Link to post
Share on other sites
zouleo
I think I've figured this out now (almost). What I _really_ want is a new "Main Content"-section. I think the code for this section is stored inside section.postloop.php. So I should be able to copy this section and modify it so that it uses my custom query for the loop, instead of the default loop. Right? But, I've looked at the section.postloop.php file and I don't know where to add my custom query....

Share this post


Link to post
Share on other sites
zouleo
Ok. So now I've figured out where to add the custom query. In have a copy of section.postloop.php that I've renamed. I've also added the information about the new section in functions.php. In my copy of section.postloop.php I just add 'workswith' =>'templates' and I also added query_posts('category_name=special_cat&posts_per_page=10'); before get_template_part( 'template.postloop' ); In Template Setup => Select Template Area and then I choose my Custom Page and add the new section. And that's it. It is working now!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this  

×