• I’ve recently added a Related Posts feature to my blog and it does the job on blog posts such as this, however, I don’t want the Related Posts to feature on my blogroll as it is at the moment. On the blogroll, I’d rather just have the post title and preview and only have the Related Posts underneath the blog itself on the post page.

    Rather than use a plug in, I found the code to add the Related Posts manually into the loop.php file. It looks like this:

    <!--related-->
    			<div class="relatedposts">
    			<h3>Related posts</h3>
    			<?php
    				$orig_post = $post;
    				global $post;
    				$tags = wp_get_post_tags($post->ID);
    
    				if ($tags) {
    				$tag_ids = array();
    				foreach($tags as $individual_tag) $tag_ids[] = $individual_tag->term_id;
    				$args=array(
    				'tag__in' => $tag_ids,
    				'post__not_in' => array($post->ID),
    				'posts_per_page'=>4, // Number of related posts to display.
    				'caller_get_posts'=>1
    				);
    
    				$my_query = new wp_query( $args );
    
    				while( $my_query->have_posts() ) {
    				$my_query->the_post();
    				?>
    
    				<div class="relatedthumb">
    					<a rel="external" href="<? the_permalink()?>"><?php the_post_thumbnail(array(150,100)); ?><br />
    					<?php the_title(); ?>
    					</a>
    				</div>
    
    				<? }
    				}
    				$post = $orig_post;
    				wp_reset_query();
    				?>
    			</div>
    			<!-- /related-->

    At the moment, it’s sitting before the footer and underneath this:

    <div class="content">
    				<?php the_content( __( 'Continue reading <span class="meta-nav">→</span>', 'blaskan' ) ); ?>
    				<?php wp_link_pages( array( 'before' => '<nav class="page-link" role="navigation">' . __( 'Pages:', 'blaskan' ), 'after' => '</nav>' ) ); ?>
    
    				<?php if ( !is_single() && !get_the_title() ) : ?>
    					<p>
    						<a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'blaskan' ), the_title_attribute( 'echo=0' ) ); ?>">
    						<?php _e( 'Continue reading <span class="meta-nav">→</span>', 'blaskan' ); ?>
    						</a>
    					</p>
    				<?php endif; ?>
    			</div>
    			<!-- / .content -->

    Now, I’ve tried putting the Related Posts code in a few different places within the <div class=”content”> tag and this doesn’t work. So I’m wondering whether there’s another way to do it, so that the Related Posts can be hidden on the blogroll page and only display after the user clicks ‘Continue reading’ and lands on the post page?

    Any help on this is greatly appreciated and if you need any more information from me, please just ask.

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘How can I hide Related Posts from blogroll? (Blaskan Theme)’ is closed to new replies.