Support » Developing with WordPress » How to add text at the end of post on last page only

  • Resolved muchmuch11

    (@muchmuch11)


    How to add text at the end of post but only on the last page only (multiple pages post)? I have some posts that have multiple pages.

    I have this code but this will show at the end of post on every pages

    function author_end_post($content) {
    	if (is_single()) {
    		$content .= '<div id="author">test</div>';
    	}
    	return $content;
    }
    
    add_filter ('the_content', 'author_end_post', 0);
    

    Thanks for the help!

    • This topic was modified 1 year, 7 months ago by  muchmuch11.
    • This topic was modified 1 year, 7 months ago by  muchmuch11.
    • This topic was modified 1 year, 7 months ago by  muchmuch11.
Viewing 1 replies (of 1 total)
  • Answering my own question, using this function:

    global $multipage, $numpages, $page;
    if( $multipage && $page == $numpages )
        echo 'last page';

    Resolved.

    • This reply was modified 1 year, 7 months ago by  muchmuch11.
Viewing 1 replies (of 1 total)
  • The topic ‘How to add text at the end of post on last page only’ is closed to new replies.