WordPress.org

Ready to get started?Download WordPress

Forums

How do I list a summary of posts (10 posts)

  1. Novakeo
    Member
    Posted 9 years ago #

    I was wondering how I would go about having the main(index) page display only a summary of say -- a list of posts in a category that I define to display on the home page, similar to someone clicking on a category and a summary of the latest post in the cat is diplayed.

    I hope I explained it weel enough.

  2. Kafkaesqui

    Posted 9 years ago #

    Are you asking as to how you can display summaries for all posts on your home page, or only in a specific category?

    If your theme has a single.php template, you can edit your index.php and where it has:

    <?php the_content(); ?>

    change it to:

    <?php the_excerpt(); ?>

    This hits all posts as they normally appear on your home page. If you were looking for some sort of restriction on this (based on category or whatnot), provide a little more detail as to what you're looking to do.

  3. Novakeo
    Member
    Posted 9 years ago #

    Thanks Kafkaesqui, What I am looking to do, is to have on my home page, is an exerpt for two different categories, the user will only see a summary for the posts, for the two categories.

  4. Kafkaesqui

    Posted 9 years ago #

    If this is to be in the normal flow of posts (i.e. The Loop), you could use this:

    <?php if(in_category(1) || in_category(2)) : ?>
    <?php the_excerpt(); ?>
    <?php else : ?>
    <?php the_content(); ?>
    <?php endif; ?>

    Just change the # in the in_category() functions to the numeric IDs of the categories you want to affect. If it's separate from The Loop, say a list in the sidebar or whatnot, you can use something along these lines for each category of posts:

    http://wordpress.org/support/topic.php?id=30153#post-170444

    (Just change showposts to the # of posts to display; you can use any templates tags in this form of the loop, i.e. <?php the_excerpt(); ?> .)

  5. CordlessToxin
    Member
    Posted 9 years ago #

    I'm afraid chaning all the [_content] into [_excerpt] makes the Full Story unreadable.

    <div class="storycontent">
    <?php the_content(__('(more...)')); ?>
    </div>

    Is the only place in the index.php where it can be changed. Changing it makes EVERY single page display only the excerpt, I couldn't get it to show the full article after you click on the title.

  6. Lorelle
    Member
    Posted 9 years ago #

    I'm not sure what you are trying to do, but to change more statement should read:

    <?php the_content('more....'); ?>

    See: http://codex.wordpress.org/Customizing_the_Read_More

  7. CordlessToxin
    Member
    Posted 9 years ago #

    Thanks for that link, that's kinda what I'm trying to get done.

    Only the thing is, When you use the <!--more--> tag, it recopies what you showed in your excerpt.

    Grab a copy of the Index.php and take a look. The
    <?php the_content('more....'); ?>
    cannot be moved anywhere else on the page.

    I'd like to make it so that when I click on the [TITLE]
    <?php the_permalink() ?>
    it takes me to the full story.

    While viewed from a normal page, I just want the header to show up, no excerpt, no summery. Just title.

    I tried removing the_content and placing it as the link to the title
    via->
    <div class="post">
    <h3 class="storytitle" id="post-<?php the_ID(); ?>"><a href="<?php the_content() ?>" rel="bookmark"><?php the_title(); ?></a></h3>

    but that doesn't work.

  8. Novakeo
    Member
    Posted 9 years ago #

    Thanks Kafkaesqui, that is what I wanted to do. It works fine.

  9. Kafkaesqui

    Posted 9 years ago #

    CordlessToxin: One solution is to create a template called "single.php" and copy your index.php into it, making sure to use the_content() for displaying the post in single.php, and the_excerpt() in index.php.

  10. CordlessToxin
    Member
    Posted 9 years ago #

    Op.. nevermind, I tweaked it to death and found a way around, I'll post this here in case anyone in the future wants to do something odd like I did... o_O(yeah I couldn't make up my mind)

    In index.php I deleted the code that handled showing how many comments a post had, and deleted the code that showed the author, categories of the post, and time it was posted. This looks a lot neater and cleans things up

    then...
    replace the <?php the_content(__('(more...)')); ?>
    with
    <?php if(is_category(1))
    {
    } else {
    the_content('&raquo; &raquo; &raquo;');
    } ?>
    </div>

    to make category 1 be the page that shows nothing but titles.
    In my case I decided to display very short excerpts by using the <!--more--> technique. That's when you write a post normally, type a sentance or two, insert <!--more--> and keep typeing. It'll take everything before the <!--more--> and use that as a summery.

    I made a category called "all entries" (category(1)) and set it so that when I click that category all the summeries dissapear leaving ONLY the titles.

    To make this for all categories put this in stead...
    <?php if(is_category())
    {
    } else {
    the_content('&raquo; &raquo; &raquo;');
    } ?>
    </div>

    This will make it so that the main page(when you click your blog's title / can't be avoided) shows things with short summeries, but if clicking on any category to navigate, summeries will dissapear.

    My webiste's http://www.CordlessToxin.com , head over and check how it turned out.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.