WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Show excerpts on a static frontpage (11 posts)

  1. kgud
    Member
    Posted 2 years ago #

    Hi there

    I'm working on a site where the frontpage is a static one and the posts are elsewhere in the navigation. I have in the Settings told WordPress which of my page should be the front and which should be the posts page.

    I want to show excerpts of all the posts (not only from one cat) on that static frontpage, which btw uses its own page template.

    This is the site in question: http://beta.nitta.is/yogashala/
    As you can see I have put some kind of a loop on the frontpage page template, but it isn't showing posts.. nor excerpts.

    Would really appreciate help from you guys.
    Thanks in advance.

    Kristín

  2. Jonas Grumby
    Member
    Posted 2 years ago #

    The easiest way would be to let the home page be the main blog page and use the_excerpt in the loop instead of the_content.

  3. kgud
    Member
    Posted 2 years ago #

    Thanks, but I need the main blogpage to be elsewhere in the navigation showing the full posts.

    Only wanted few excerpts on the frontpage as a teaser.

    Any idea on that?

  4. alchymyth
    The Sweeper & Moderator
    Posted 2 years ago #

    As you can see I have put some kind of a loop on the frontpage page template,

    no, can't see anything from the link

    - please paste the full code of that template into a http://pastebin.com/ and post the link to it here - see http://codex.wordpress.org/Forum_Welcome#Posting_Code

    do you want to show the posts and the page content?

    general:
    http://codex.wordpress.org/Class_Reference/WP_Query

  5. kgud
    Member
    Posted 2 years ago #

  6. Jonas Grumby
    Member
    Posted 2 years ago #

    That looks about right. To use that as the template for a static home page, you have to name it front-page.php.

    http://codex.wordpress.org/Template_Hierarchy

  7. kgud
    Member
    Posted 2 years ago #

    I have done that, named it front-page.php.. still not getting excerpts but am getting the page title "FORSÍÐA".. maybe something wrong with my loop?

    I'm beyond my knowledge at the moment.

  8. alchymyth
    The Sweeper & Moderator
    Posted 2 years ago #

    you need to add a query before the loop; i.e. before this line <?php if (have_posts()) : ?>

    show excerpts of all the posts

    example:

    <?php query_posts('cat=0&posts_per_page=-1'); ?>

    http://codex.wordpress.org/Function_Reference/query_posts

  9. kgud
    Member
    Posted 2 years ago #

    THANK YOU :)

    It's working!

    K

  10. kgud
    Member
    Posted 2 years ago #

    Hi guys again

    Do you know why new posts I make is not appearing in the excerpts on the frontpage?

    It does appear if I change the cat to Uncategorized.

    I also have a page which displays posts in one category, those posts are not appearing at the front...I have tried to have the posts in two cat, but that did not work.

    Hope you can help me with this as brilliantly as you did before.

    K

  11. jglovier
    Member
    Posted 1 year ago #

    Instead of the above query_posts parameters, try it like this (where the number 1 is however many posts you'd like to display:

    <?php query_posts('showposts=1'); ?>

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.