Duplicate Blog Indexes 'Older Posts Pages'
-
Hi, I am having a problem with a client’s site where the loop file isn’t working and so when it returns the ‘older posts’ pages which have the urls ‘blog/page/1/’ 2, 3 and 4…they show the same 10 excerpts as the main blog home
I’ve given up trying to fix the loop file but wanted to know how I can delete the duplicate ‘older posts’ pages, I’ve managed to take out the ‘Older Entries’ footer on the main blog home but want to actually delete the pages 2, 3,4
here’s an example of the pages https://tinyurl.com/bwobf4x
please don’t post the url of my clients site in responses I’m trying not to post unnatural links around the web.
-
Howdy,
You should not give up on the loop file problem.
You won’t be able to naturally remove pages 2, 3, 4… they are just listing pages pulling in posts from your database.Can you use Pastebin and provide your loop file? Or the area in your template where the loop is called?
Can probably help out easily.
Take care,
Paul<?php /** * The loop that displays posts. * * The loop displays the posts and the post content. See * https://codex.www.ads-software.com/The_Loop to understand it and * https://codex.www.ads-software.com/Template_Tags to understand * the tags used in it. * * This can be overridden in child themes with loop.php or * loop-template.php, where 'template' is the loop context * requested by a template. For example, loop-index.php would * be used if it exists and we ask for the loop with: * <code>get_template_part( 'loop' , 'index');</code> */ ?> <?php /* If there are no posts to display, such as an empty archive page */ ?> <?php if ( ! have_posts() ) : ?> <div id="post-0" class="post error404 not-found"> <h1 class="entry-title"><?php _e( 'Not Found', 'twentyten' ); ?></h1> <div class="entry-content"> <p><?php _e( 'Apologies, but no results were found for the requested archive. Perhaps searching will help find a related post.', 'twentyten' ); ?></p> <?php get_search_form(); ?> </div><!-- .entry-content --> </div><!-- #post-0 --> <?php endif; ?> <?php /* Start the Loop. * * In Twenty Ten we use the same loop in multiple contexts. * It is broken into three main parts: when we're displaying * posts that are in the gallery category, when we're displaying * posts in the asides category, and finally all other posts. * * Additionally, we sometimes check for whether we are on an * archive page, a search page, etc., allowing for small differences * in the loop on each template without actually duplicating * the rest of the loop that is shared. * * Without further ado, the loop: */ ?> <?php query_posts($query_string . '&cat=-4'); ?> <?php while ( have_posts() ) : the_post(); ?> <?php /* How to display posts of the Gallery format. The gallery category is the old way. */ ?> <?php if ( ( function_exists( 'get_post_format' ) && 'gallery' == get_post_format( $post->ID ) ) || in_category( _x( 'gallery', 'gallery category slug', 'twentyten' ) ) ) : ?> <div id="post-<?php the_ID(); ?>" <?php post_class(); ?>> <h2 class="entry-title"><a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'twentyten' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php the_title(); ?></a></h2> <div class="entry-meta"> <?php twentyten_posted_on(); ?> </div><!-- .entry-meta --> <div class="entry-content"> <?php if ( post_password_required() ) : ?> <?php the_content(); ?> <?php else : ?> <?php $images = get_children( array( 'post_parent' => $post->ID, 'post_type' => 'attachment', 'post_mime_type' => 'image', 'orderby' => 'menu_order', 'order' => 'ASC', 'numberposts' => 999 ) ); if ( $images ) : $total_images = count( $images ); $image = array_shift( $images ); $image_img_tag = wp_get_attachment_image( $image->ID, 'thumbnail' ); ?> <div class="gallery-thumb"> <a class="size-thumbnail" href="<?php the_permalink(); ?>"><?php echo $image_img_tag; ?></a> </div><!-- .gallery-thumb --> <p><em><?php printf( _n( 'This gallery contains <a %1$s>%2$s photo</a>.', 'This gallery contains <a %1$s>%2$s photos</a>.', $total_images, 'twentyten' ), 'href="' . get_permalink() . '" title="' . sprintf( esc_attr__( 'Permalink to %s', 'twentyten' ), the_title_attribute( 'echo=0' ) ) . '" rel="bookmark"', number_format_i18n( $total_images ) ); ?></em></p> <?php endif; ?> <?php the_excerpt(); ?> <?php endif; ?> </div><!-- .entry-content --> <div class="entry-utility"> <?php if ( function_exists( 'get_post_format' ) && 'gallery' == get_post_format( $post->ID ) ) : ?> <a href="<?php echo get_post_format_link( 'gallery' ); ?>" title="<?php esc_attr_e( 'View Galleries', 'twentyten' ); ?>"><?php _e( 'More Galleries', 'twentyten' ); ?></a> <span class="meta-sep">|</span> <?php elseif ( in_category( _x( 'gallery', 'gallery category slug', 'twentyten' ) ) ) : ?> <a href="<?php echo get_term_link( _x( 'gallery', 'gallery category slug', 'twentyten' ), 'category' ); ?>" title="<?php esc_attr_e( 'View posts in the Gallery category', 'twentyten' ); ?>"><?php _e( 'More Galleries', 'twentyten' ); ?></a> <span class="meta-sep">|</span> <?php endif; ?> <span class="comments-link"><?php comments_popup_link( __( 'Leave a comment', 'twentyten' ), __( '1 Comment', 'twentyten' ), __( '% Comments', 'twentyten' ) ); ?></span> <?php edit_post_link( __( 'Edit', 'twentyten' ), '<span class="meta-sep">|</span> <span class="edit-link">', '</span>' ); ?> </div><!-- .entry-utility --> </div><!-- #post-## --> <?php /* How to display posts of the Aside format. The asides category is the old way. */ ?> <?php elseif ( ( function_exists( 'get_post_format' ) && 'aside' == get_post_format( $post->ID ) ) || in_category( _x( 'asides', 'asides category slug', 'twentyten' ) ) ) : ?> <div id="post-<?php the_ID(); ?>" <?php post_class(); ?>> <?php if ( is_archive() || is_search() ) : // Display excerpts for archives and search. ?> <div class="entry-summary"> <?php the_excerpt(); ?> </div><!-- .entry-summary --> <?php else : ?> <div class="entry-content"> <?php the_content( __( 'Continue reading <span class="meta-nav">→</span>', 'twentyten' ) ); ?> </div><!-- .entry-content --> <?php endif; ?> <div class="entry-utility"> <?php twentyten_posted_on(); ?> <span class="meta-sep">|</span> <span class="comments-link"><?php comments_popup_link( __( 'Leave a comment', 'twentyten' ), __( '1 Comment', 'twentyten' ), __( '% Comments', 'twentyten' ) ); ?></span> <?php edit_post_link( __( 'Edit', 'twentyten' ), '<span class="meta-sep">|</span> <span class="edit-link">', '</span>' ); ?> </div><!-- .entry-utility --> </div><!-- #post-## --> <?php /* How to display all other posts. */ ?> <?php else : ?> <div id="post-<?php the_ID(); ?>" <?php post_class(); ?>> <h2 class="entry-title"><a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'twentyten' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php the_title(); ?></a></h2> <div class="entry-meta"> <?php twentyten_posted_on(); ?> </div><!-- .entry-meta --> <?php if ( is_archive() || is_search() ) : // Only display excerpts for archives and search. ?> <div class="entry-summary"> <?php the_excerpt(); ?> </div><!-- .entry-summary --> <?php else : ?> <div class="entry-content"> <?php the_content( __( 'Continue reading <span class="meta-nav">→</span>', 'twentyten' ) ); ?> <?php wp_link_pages( array( 'before' => '<div class="page-link">' . __( 'Pages:', 'twentyten' ), 'after' => '</div>' ) ); ?> </div><!-- .entry-content --> <?php endif; ?> <div class="entry-utility"> <?php if ( count( get_the_category() ) ) : ?> <span class="cat-links"> <?php printf( __( '<span class="%1$s">Posted in</span> %2$s', 'twentyten' ), 'entry-utility-prep entry-utility-prep-cat-links', get_the_category_list( ', ' ) ); ?> </span> <span class="meta-sep">|</span> <?php endif; ?> <?php $tags_list = get_the_tag_list( '', ', ' ); if ( $tags_list ): ?> <span class="tag-links"> <?php printf( __( '<span class="%1$s">Tagged</span> %2$s', 'twentyten' ), 'entry-utility-prep entry-utility-prep-tag-links', $tags_list ); ?> </span> <span class="meta-sep">|</span> <?php endif; ?> <span class="comments-link"><?php comments_popup_link( __( 'Leave a comment', 'twentyten' ), __( '1 Comment', 'twentyten' ), __( '% Comments', 'twentyten' ) ); ?></span> <?php edit_post_link( __( 'Edit', 'twentyten' ), '<span class="meta-sep">|</span> <span class="edit-link">', '</span>' ); ?> </div><!-- .entry-utility --> </div><!-- #post-## --> <?php endif; // This was the if statement that broke the loop into three parts based on categories. ?> <?php endwhile; // End the loop. Whew. ?>
I don’t know why but the search box, categories and older entries don’t display the relevant posts..It seemed as though the original web design didn’t bother configuring it correctly..
I don’t know enough about it to fix it myself..I’m an SEO/Graphic DesignerHowdy,
In this part of the code, the pagination gets screwed up:
* Without further ado, the loop: */ ?> <?php query_posts($query_string . '&cat=-4'); ?> <?php while ( have_posts() ) : the_post(); ?>
query_posts will mess up pagination and some other things.
(Note: this query_posts line was not in the original 2010 loop.php.)This post I found can help you fix that:
https://stylizedweb.com/2008/08/13/query_posts-pagination-problem/If you go that route, you might want to put back your “Older” and “Newer” links.
Let me know how this works out.
Take care,
PaulP.S. — Please Use Pastebin when communicating more than 10 lines of code in the future.
Hi FreakingID, when I try to replace the line in your last post with:
<?php if (have_posts()) : ?> <?php $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; query_posts("category_name=somecat&paged=$paged"); ?> <?php while (have_posts()) : the_post(); ?>
I refresh the blog home and it just displays the page header and nothing else :S
[ Please do not bump, that’s not permitted here. ]
Richieb, you’re very close. Some of what you had above was just example from the link I sent. Replace the 3 lines you just gave me above with the following:
<?php if ( have_posts() ) : $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; query_posts($query_string . "&cat=-4&paged=$paged"); while (have_posts()) : the_post(); ?>
Let me know if it works.
Regards,
Paul* Without further ado, the loop: */ ?> <?php query_posts($query_string . '&cat=-4'); ?> <?php while ( have_posts() ) : the_post(); ?>
I replaced the above with the code you mentioned in the above and I still only get the website header file… I don’t know too much about this but perhaps something is wrong in one of the other files?
Please use Pastebin again and post the entire file where you made this change.
Also, what theme are you using?
If it is custom built, did you start with a particular theme / framework?Paul
I think it used Twenty Ten, although it was a previous Seo who made customization to it and they are not very helpful any longer
Here is the loop.php on pastebin
Howdy,
I’ve altered the file and used pastebin to just send the whole thing back.
Make sure to keep a copy of your original, just in case…Try it out,
PaulHi freakingid.. I copied and paste the new version in the Raw paste Data box at the bottom into the Loop.php in WordPress and when I check to see if mysite.co.uk/blog/2 has different excerpts to the main blog page it still shows the same 20 excerpts…
this is where I’m stuck, I searched all over to figure out why it does this for several months now
and when you type a search term in the search box it takes you to the sites homepage
Thanks for trying, although Im sure I’m never going to get this tidied up… I would be happy if I could just get around the duplicate excerpts on the blog/2 blog/3 pages etc
Okay, the weird thing is now:
1. Page 1 and Page 2 display the same posts.
2. But if you go on and do Page 3, and so forth, things start acting the way they should.
Hmm.Hi FreakingID… It still seems to have identical excerpts on all pages from what I see ?? any ideas on this one? I knew something is wrong
- The topic ‘Duplicate Blog Indexes 'Older Posts Pages'’ is closed to new replies.