WordPress.org

Support

Support » How-To and Troubleshooting » [Resolved] Echo Title in wp_link_pages

[Resolved] Echo Title in wp_link_pages

  • 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

Viewing 8 replies - 1 through 8 (of 8 total)
  • esmi

    @esmi

    Forum Moderator

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

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

    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

    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.

    esmi

    @esmi

    Forum Moderator

    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

    Bummer, well that shows nothing at all now… Ah heck. 😉

    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.

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

    Thanks a bunch for the help.

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘[Resolved] Echo Title in wp_link_pages’ is closed to new replies.
Skip to toolbar