WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Echo Title in wp_link_pages (9 posts)

  1. rhythmdoctor
    Member
    Posted 5 years ago #

    Hello,

    I am trying to create multi-paged posts with a link at the bottom that says "Continue Reading POSTNAME - Part 1,2,etc..."

    I cant figure out how to echo the title/postname in this link. So far I have

    <?php wp_link_pages('before=Continue Reading - &after='); ?>

    I keep thinking that this must be simple but cant seem to figure out. Have tried putting

    <?php wp_link_pages('before=Continue Reading <?php the_title(); ?> - &after='); ?> and tried with "echo" in there as well... What am I missing. Any help would be greatly appreciated. Thanks

  2. esmi
    Forum Moderator
    Posted 5 years ago #

    You've got a nested <?php...?> there. Try:

    <?php wp_link_pages('before=Continue Reading '.the_title().' - &after='); ?>

  3. rhythmdoctor
    Member
    Posted 5 years ago #

    Thanks a bunch. Only problem is that it switches the title with "continue reading" so that Continue reading is after the post title. Title shows though so that is a start.. Got to figure out how to have it, for example do

    Continue Reading - This is my Post title - Part 1 2

  4. rhythmdoctor
    Member
    Posted 5 years ago #

    Also noticed that this shows the title on pages that dont have <!nextpage> assigned - so it is showing the title at the bottom of all posts. Hmmm.

  5. esmi
    Forum Moderator
    Posted 5 years ago #

    Only problem is that it switches the title with "continue reading"

    Doh! Forgot about that problem. you need to use get_the_title().

    Try:

    <?php if(is_paged()) wp_link_pages('before=Continue Reading '.get_the_title().' - &after='); ?>

    is_paged

  6. rhythmdoctor
    Member
    Posted 5 years ago #

    Bummer, well that shows nothing at all now... Ah heck. ;-)

  7. rhythmdoctor
    Member
    Posted 5 years ago #

    This seems to almost work -
    <?php wp_link_pages('before=Continue Reading - '.get_the_title().' - Part &after='); ?>

    Except 1) "-Part" Doesnt show and 2) The title only shows 2 words... hmm.

    Thanks though, this is much better.

  8. rhythmdoctor
    Member
    Posted 5 years ago #

    Ahhh, I had a "&" in my title and it seemed to choke on that. Once I changed it to "and", it worked...

  9. rhythmdoctor
    Member
    Posted 5 years ago #

    Thanks a bunch for the help.

Topic Closed

This topic has been closed to new replies.

About this Topic