WordPress.org

Ready to get started?Download WordPress

Forums

Novice PHP question (3 posts)

  1. Bricolou
    Member
    Posted 8 years ago #

    I'm using the excerpt for my archive and category pages and would like to put a "Read this post" link at the bottom of the excerpt without the link showing up when the post is unfolded.
    I've got this working: <?php if(is_category() || is_archive()) { echo '<a href="#">Lire la suite...</a>' ; } ?>
    But when I put <a href="<?php the_permalink(); ?>"> where the "#" is, it doesn't work.
    Sorry to be so daft, but can anyone tell me what I'm doing wrong - I've already pulled out most of my hair!

  2. Bricolou
    Member
    Posted 8 years ago #

    OK, OK, found it!
    <?php
    if ($single)
    the_content();
    else {
    the_excerpt();
    if (!empty($post->post_excerpt))
    {
    ?> </div>
    <a href="<?php the_permalink(); ?>">Read this post</a>
    <?php
    }
    }
    ?>

    Thanks to those people in this thread :
    http://wordpress.org/support/topic/53855?replies=12

    Would be easier if the WP support forum search function was working.

  3. syncbox
    Member
    Posted 8 years ago #

    thanks for sharing... I was able to take this and modify it for my custom theme easily.

    thanks!

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags