WordPress.org

Forums

Single.php - Exclude Current Post Link from Archive List (1 post)

  1. sirenetta1
    Member
    Posted 6 years ago #

    Hello,

    I have a template I created from single.php for one of my category posts.

    The template shows the full post from one of the categories, followed by an archive list of posts from that category.

    However, the archive list currently shows ALL posts from that category, including the link to the full post. Is there an automatic way to exclude the full post link from the list (since it is already showing on the page)?

    For example:

    "Pears" full text

    Archive list

    "Pears" link
    "Bananas" link
    "Apples" link

    (I do not want "Pears" to show)

    Here is the code I have right now...

    <?php if (have_posts()) : ?>
    <?php $count = 0; ?>
    <?php while (have_posts()) : the_post(); ?>
    <?php $count++; ?>
      <?php if ($count < 2) : ?>
    
    <!--Show current post-->
    
    <h2><?php the_title(); ?></h2>
    
    <?php the_content() ?>
    
    <h2>Archived Entries</h2>
    
       <?php else : ?>
    
    <?php endif; ?>
    <?php endwhile; ?>
    <?php endif; ?>
    
    <!--Show posts from category 3-->
    
    <?php query_posts('cat=3'); ?>
    
    <?php while (have_posts()) : the_post(); ?>
    
    <a href='<?php the_permalink() ?>'><?php the_title(); ?></a>
    
    <?php the_excerpt(); ?>
    
    <?php endwhile; ?>

Topic Closed

This topic has been closed to new replies.

About this Topic