• Resolved leekaidragon

    (@leekaidragon)


    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?

Viewing 12 replies - 1 through 12 (of 12 total)
  • MichaelH

    (@michaelh)

    Thread Starter leekaidragon

    (@leekaidragon)

    thnks 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?

    MichaelH

    (@michaelh)

    Actually you should read Template Hierarchy to understand what template WordPress uses to display posts in certain conditions.

    Thread Starter leekaidragon

    (@leekaidragon)

    when i use

    https://www.mywebsite.com/&r_orderby=desc

    the 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?

    MichaelH

    (@michaelh)

    https://www.mywebsite.com/&r_orderby=desc

    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().

    Thread Starter leekaidragon

    (@leekaidragon)

    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 – https://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?

    MichaelH

    (@michaelh)

    Use the Page of Posts example in the Pages article.

    Thread Starter leekaidragon

    (@leekaidragon)

    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 : https://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?

    MichaelH

    (@michaelh)

    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_Display

    Also review
    Excerpt
    Customizing_the_Read_More

    Thread Starter leekaidragon

    (@leekaidragon)

    But 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?

    MichaelH

    (@michaelh)

    You would replace the_content with the_excerpt in your page template (which you copied from your index.php)

    Thread Starter leekaidragon

    (@leekaidragon)

    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!

Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘query_post template’ is closed to new replies.