How do I list a summary of posts
-
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.
-
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.
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.
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(); ?>
.)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.
I’m not sure what you are trying to do, but to change more statement should read:
<?php the_content('more....'); ?>
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.
Thanks Kafkaesqui, that is what I wanted to do. It works fine.
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, andthe_excerpt()
in index.php.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('» » »');
} ?>
</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('» » »');
} ?>
</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.
- The topic ‘How do I list a summary of posts’ is closed to new replies.