• I’m building a theme that needs to have the “Read More” link placed outside of the post content. Right now my code looks like this:

    <?php the_content('Read More'); ?>

    Which results in this:

    <p>The post content. <a href="..." class="more-link">Read More</a></p>

    … but this is what I need:

    <p>The post content.</p>
    <a href="..." class="more-link">Read More</a>

    I can’t set more-link as a block element because I need it to float, which causes it to interact incorrectly with the paragraph content its contained in. I would prefer not to use the_excerpt unless I have to.

    Is there maybe some way to do this in the theme’s functions.php? Thanks for any help!

Viewing 4 replies - 1 through 4 (of 4 total)
  • <?php the_content('', false,'');?>
    <a href="<?php the_permalink();?>#more-<?php echo $post->ID;?>"><?php _e('Read more');?></a>
    Thread Starter ericcarl

    (@ericcarl)

    Thanks esmi! That does work but it also includes the “Read More” link on every post, not just on the ones using the “Read More” quicktag. Is there a way to do something like this, that checks to see if the Read More link is necessary or not?

    <if read more is used in the post><a>Read More</a></if>

    So far, I’ve not found a foolproof way of doing this that wouldn’t have a pretty big performance hit as you’d have to parse the content of every post for the <--more--> tag.

    Thread Starter ericcarl

    (@ericcarl)

    All right, thanks for the help!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Place "Read More" link outside of post content’ is closed to new replies.