Only Display Latest 10 Posts on Homepage and Nothing More – 2010 Theme
-
How can I Only Display Latest 10 Posts on Homepage and Nothing More – 2010 Theme. i.e. do not display previous posts from 11 onwards. Just the latest 10 posts please. I can’t seem to find a code that do this.
I’ve done display 10 posts per pages but no 11 post onwwards are displayed on pages 2 and so forth.
The reason why I wanted this is, I had enabled indexing of categories, some of which has 2 sub-sub categries.
An option that I can think of is to place a disallow rule on site.com/page/. But I’m worried if this is the best way to do this.
-
Try changing:
<?php if ( $wp_query->max_num_pages > 1 ) : ?> <div id="nav-below" class="navigation"> <div class="nav-previous"><?php next_posts_link( __( '<span class="meta-nav">←</span> Older posts', 'twentyten' ) ); ?></div> <div class="nav-next"><?php previous_posts_link( __( 'Newer posts <span class="meta-nav">→</span>', 'twentyten' ) ); ?></div> </div><!-- #nav-below --> <?php endif; ?>to:
<?php if ( $wp_query->max_num_pages > 1 & is_home() ) : ?> <div id="nav-below" class="navigation"> <div class="nav-previous"><?php next_posts_link( __( '<span class="meta-nav">←</span> Older posts', 'twentyten' ) ); ?></div> <div class="nav-next"><?php previous_posts_link( __( 'Newer posts <span class="meta-nav">→</span>', 'twentyten' ) ); ?></div> </div><!-- #nav-below --> <?php endif; ?>in loop.php
Hiya esmi
This didn’t do the trick. previous posts are still shown on home.com/page/2, home.com/page/3 etc…
All I need is to just show the latest 10 posts on homepage. Just a link and perhaps a 200 character snippet on each. Nothing else as Categories/Sub Categories are indexed.
Something similar to ezinearticles.com, they only have about 50 latest posts with excerpt, no page 2 and so on. The rest of the posts are viewable via their categoroes/sub cats.
Hope it makes sense.
have you tried to simply remove the links to next/previous posts?
find it in loop.php of the original Twenty Ten theme:
from line 22:
<?php /* Display navigation to next/previous pages when applicable */ ?> <?php if ( $wp_query->max_num_pages > 1 ) : ?> <div id="nav-above" class="navigation"> <div class="nav-previous"><?php next_posts_link( __( '<span class="meta-nav">←</span> Older posts', 'twentyten' ) ); ?></div> <div class="nav-next"><?php previous_posts_link( __( 'Newer posts <span class="meta-nav">→</span>', 'twentyten' ) ); ?></div> </div><!-- #nav-above --> <?php endif; ?>and from line 170:
<?php /* Display navigation to next/previous pages when applicable */ ?> <?php if ( $wp_query->max_num_pages > 1 ) : ?> <div id="nav-below" class="navigation"> <div class="nav-previous"><?php next_posts_link( __( '<span class="meta-nav">←</span> Older posts', 'twentyten' ) ); ?></div> <div class="nav-next"><?php previous_posts_link( __( 'Newer posts <span class="meta-nav">→</span>', 'twentyten' ) ); ?></div> </div><!-- #nav-below --> <?php endif; ?>Thanks alchymyth, but removing the next/previous links simply remove the links. It doesn’t stop wordpress from having home.com/page/2. home.com/page/3 etc….
My real concern is seo as there’s so much page where a post can be access:
home.com/page/6
home.com/category/wordpress/page/4
home.com/category/wordpress/seo/page/2
home.com/category/wordpress/seo/onpage-optimisationI’m only using excerpt by the way and the full content only shown in the actual post.
If anyone has any brilliant idea on how to tackle this or a better alternative, it’ll be much appreciated.
Many Thanks
only my personal opinion:
search engines will only follow links within the blog;
if there is no link – there is no seo influence.and if you have linked the post via categories, they will be found there as well.
imho, if the link with ‘home.com/page/6’ does not exist, it will not ‘dilute’ the search result.
image all the possible ‘blog’ search combinations, that will lead to the posts being shown by search.php – endless paths to get to the posts.
the only ‘real solution’ is to delete everything that is exeeding the 10 posts on the front.
there might be also the possibility to use robots.txt to add a lot of ‘nofollow’ paths
I’m happy with having a single post indexed on a variety of categories/subcategories:
home.com/category/wordpress/page/4
home.com/category/wordpress/seo/page/2
home.com/category/wordpress/seo/onpage-optimisationAll I want is that it doesn’t show up on homepage/paged homepage as in this case:
home.com/page/6I wish someone is willing to share the code to make it possible for me to display only the latest post:
http://themeshaper.com/demo/featuresite/
This theme is able to show the recent post on homepage, but having a bit of an excerpt would be a bonus.
I’m using wordpress 2010 theme.
many Thanks in advance. I appreciate both of you who had been very patient with me.
the link to ‘themeshaper’ does exactly what i suggested:
i does not show the links to next/prev posts on the front page;these are still there if you type the right link, for instance:
http://themeshaper.com/demo/featuresite/?paged=2on this page, you will find the next/prev posts links again.
ps:
if you want the excerpts on the frontpage in Twenty Ten, edit loop.php
(the folowing line apears twice; the second one more towards the end , line 132, is for ‘normal’ posts):<?php if ( is_archive() || is_search() ) : // Only display excerpts for archives and search. ?>and change it to:
<?php if ( is_home() || is_front_page() || is_archive() || is_search() ) : // Only display excerpts on home page and for archives and search. ?>Quick piece of info regarding not paging results.
http://codex.wordpress.org/Function_Reference/query_posts#Pagination_Parameters
See the
nopagingparameter …Hi Mark, would you be kind enough to tell me where exactly I should change with what.
Many thanks
[code moderated - replaced with pastebin]
http://wordpress.pastebin.com/edMQVUMPI’d probably use a filter myself..
add_filter( 'pre_get_posts', 'no_page_front' ); function no_page_front( $q ) { if( $q->is_front_page ) $q->set( 'nopaging', true ); return $q; }Which would go in the theme’s functions file.
Hi Mark,
Do I just add the above code anywhere on function file?
After the first
<?phpon a new line is fine…Or anywhere else, providing it’s within opening and closing php tags(
<?php?>).sorry Mark, but this didn’t work
Had no idea if it would work, i’ve not used that parameter before..
I’ll test the code and report back..
I’ve just realised something, the “Front page” is a singular page, so there’s nothing to page anyway (by default, the front page shows the content of a single page)..
If we’re dealing with the posts page, it makes sense the code didn’t work…
Change the above to..
add_filter( 'pre_get_posts', 'no_page_front' ); function no_page_front( $q ) { if( $q->is_posts_page ) $q->set( 'nopaging', true ); return $q; }
The topic ‘Only Display Latest 10 Posts on Homepage and Nothing More – 2010 Theme’ is closed to new replies.