partisanentity
Member
Posted 5 years ago #
I have looked through the forum but haven't found what I am looking for yet (i think).
Is it possible to have a list of the 10 most recent posts but only to show titles?
For example:
Recent Posts
My dog Billy
Today I ate an ant
How to install Linux
Bought a new car
Flowers
Where do you want to display those 10 recent posts?
Customizing your Sidebar has an example of doing this using the template tag, wp_get_archives.
partisanentity
Member
Posted 5 years ago #
For example on my Navigation page, above the Archives I would like to have a list of the 10 most recent posts (of course without the actual articles, just clickable titles).
I haven't tested this, but it should work. If you want to tweak it, check these out:
http://codex.wordpress.org/Template_Tags/query_posts
http://codex.wordpress.org/Template_Tags
<?php
query_posts(showposts=10);
if ( have_posts() ){
echo '<ul>';
while ( have_posts() ){
the_post(); ?>
<a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
<?php
}
echo '</ul>';
}
?>
partisanentity
Member
Posted 5 years ago #
hmm I get this error:
Parse error: parse error, unexpected ‘=’ in /home/site/public_html/web/wp-content/plugins/runPHP/runPHP.php(383) : eval()’d code on line 2
Parse error: parse error, unexpected ‘}’ in /home/site/public_html/web/wp-content/plugins/runPHP/runPHP.php(383) : eval()’d code on line 2
My bad. Left out some apostrophes.
<?php
query_posts('showposts=10');
if ( have_posts() ){
echo '<ul>';
while ( have_posts() ){
the_post(); ?>
<a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
<?php
}
echo '</ul>';
}
?>
partisanentity
Member
Posted 5 years ago #
Thanks for the help so far, but none of the code posted here worked and it seems to be conflicting with the 'run php' plugin I have installed.
I keep getting the same error as I posted earlier, the one mentioning run php.
Does anyone what I need to do to get it to work? Thank you!
partisanentity
Member
Posted 5 years ago #
Solved it, this tag worked: <?php get_archives('postbypost', 10); ?>