I am in a bit of dilemma here so bare with me. I want to add something like this code just after the content in a post:
<p>Please let me know what you think by <a href="#comment">leaving a comment</a>!</p>
To do this, I edited single.php
and added it after the content. However, the problem is that many of my posts are separated in several pages by using <!--nextpage-->
and the above code is displayed on every page. I want that line to be displayed only at the final page if the post is separated. How is such thing possible?
There are some global variables available (or not) to detect the current page number:
The best way to understand what they do is a look at the internals of
wp_link_pages()
.(bool) $GLOBALS['multipage']
isTRUE
if there is more than one page.(int) $GLOBALS['numpages']
is the amount of available pages.(int) $GLOBALS['page']
is the number of the current page.In JavaScript you can add an
onclick
handler like this now: