• Hello,

    The code I have below displays the last 20 posts made. I was wondering if its possible to isolate a specific post with a conditional to NOT have a link and only display the title.

    <?php
    $lastposts = get_posts('numberposts=20');
    foreach($lastposts as $post) :
    setup_postdata($post);
    ?>
    <li>
    <a href="<?php the_permalink(); ?>" id="post-<?php the_ID(); ?>"><?php the_title(); ?></a>
    </li>
    <?php endforeach; ?>

    ex. say i have 3 links
    link1
    link2
    link3 <- not clickable

    Say im on the link3 post. Id want link1 and link2 to have the permalinks, but i dont want link 3 to be clickable.

    Any help would be appreciated.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Out of curiosity – why would you want to do this? There may be a better solution for whatever it is you’re trying to do.

    Thread Starter machinetype

    (@machinetype)

    Well I have links on the sidebar that are links to posts. The posts are assigned a class based on which page they are on. Like if your on page 3, the link for page 3 has a white bg applied to it.

    If theres another way to make accomplish this, let me know.

    Sure there is. There’s a “Fold Page List” plugin that you can customize to use as well.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘conditional inside loop’ is closed to new replies.