query_post template
-
when i use a query_post tag like for eg: the one below –
query_posts('posts_per_page=5');It displays the full posts and also doesnt use the same stye as the index or single.php template.
how can i use the template style of index.php while displaying the query posts?
-
Copy the index.php to a new template name and then use that.
See:
Stepping Into Templates
Template Hierarchy
Category Templates
Tag Templates
Page Template
Stepping Into Template Tagsthnks for the helpful links!!!
so to show the posts using the query tag in the index.php template style , ive to create a new template with the name query.php?Actually you should read Template Hierarchy to understand what template WordPress uses to display posts in certain conditions.
when i use
http://www.mywebsite.com/&r_orderby=descthe posts are displayed in the same way as the index.php with excerpts.
but when i use<?php query_posts($query_string.'&r_orderby=desc') ?>the template used is different…
why is it so?That would cause the Template Hierarchy to be invoked.
<?php query_posts($query_string.’&r_orderby=desc’) ?>
That’s put into a specific template so really doesn’t invoke the Template Hierarchy so in the same template that you put that code you will also use the_content() or the_excerpt().
how can i show that query result in a wordpress page?
I cannot use the php query tag, cause that displays the posts in a different template style with no excerpts and all.
So right now am using a different page template with redirection to
this url – http://www.mywebsite.com/&r_orderby=desc
but this increases the page load time a lot.pls tell me how to display the post query result in a wordpress page with the index.php template style?
Use the Page of Posts example in the Pages article.
but that will only show posts from a particular category.
Actually i’m using the wp-post ratings plugin, and i want to show the top rated posts in a wordpress page using the index.php template style.
This is the php tag:<?php query_posts($query_string.'&r_sortby=most_rated&r_orderby=desc') ?>I made a new page template copying the index.php, but that didnt work, it still displayed the full posts instead of excerpts.
The link : http://www.mywebsite.com/&r_sortby=most_rated&r_orderby=desc is displaying posts in the proper way.How can i assign the index.php template to that particualr wordpress page?
it still displayed the full posts instead of excerpts.
Use the template tag, the_excerpt(), instead of the_content().
See the first four questions here to help understand:
FAQ_Layout_and_Design#Text_and_Content_DisplayAlso review
Excerpt
Customizing_the_Read_MoreBut where am i suppose to put that excerpt tag? ive no idea, which is the template file it is using to display the posts when i use that php tag in a page.
when i use the php template in a page the posts are displayed in a different style, without the author name , just the title and content(not excerpt), there are no such templates in my theme. Do you know which is that template?You would replace the_content with the_excerpt in your page template (which you copied from your index.php)
it isnt working and also showing posts inside a page is causing a lotta problems for my theme. Anyways thnks a lot for your help!!!
Im gonna stick with the page template redirection method even though it increases the page load time, theres no other option. thnks!
The topic ‘query_post template’ is closed to new replies.