• Resolved wpacct

    (@wpacct)


    Hi Sir,

    Some Background
    ———————
    – Used the related posts plugin
    – Added the code into my barecity theme’s Main Index Template (there is no single template for barecity) to show the related posts/articles.
    – Website : https://www.goal-setting-college.com

    Problem
    ———
    The issue is, after doing the above, the related articles links are showing in the main page as well as the single pages after visitors click on the ‘(Continue)’ link.

    Request
    ———
    How should I modify the main index template’s code to
    – ONLY show the related articles and other links on individual posts (i.e. after clicking the (Continue) link?
    – Not show on the pages such as “Resources”, “Archives”, “Donate” etc?

    Append below is the entire main index template’s code. The part in bold is the related posts code that I’ve added.

    Your advice is greatly appreciated!


    <?php get_header(); ?>
    <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    <div class="post" id="post-<?php the_ID(); ?>">
    <h3 class="storytitle"><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></h3>
    <div class="meta"><?php the_category(',') ?> — <?php the_author() ?> on <?php the_time('F j, Y'); ?> at <?php the_time() ?> <?php edit_post_link(__('Edit This')); ?></div>
    <div class="storycontent">
    <?php the_content(__('(Continue...)')); ?>

    <strong>Related Articles</strong>
    <ul>
    <?php related_posts(); ?>
    </ul>

    </div>
    <div class="feedback">
    <?php wp_link_pages(); ?>
    <?php comments_popup_link(__('Comments (0)'), __('Comments (1)'), __('Comments (%)')); ?>
    </div>
    <?php comments_template(); // Get wp-comments.php template ?>
    </div>
    <?php endwhile; else: ?>
    <?php _e('Sorry, no posts matched your criteria.'); ?>
    <?php endif; ?>
    <?php posts_nav_link(' — ', __('&laquo; Previous Page'), __('Next Page &raquo;')); ?>
    <?php get_footer(); ?>

Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘How to show related links only in individual posts and NOT on Pages?’ is closed to new replies.