There are some global variables available (or not) to detect the current page number:
if ( empty ( $GLOBALS['multipage'] ) or $GLOBALS['numpages'] === $GLOBALS['page'] )
echo '<a id="lastPageLink" href="#comment">comment</a>';
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:
document.getElementById("lastPageLink").onclick = function() {
window.location.hash="comment";
document.getElementById('comment').focus();
return false;
}
Related Posts:
- HTML code in Custom field
- How to detect single.php (but not single-portfolio.php)?
- Custom Single Post By Category
- Custom permalink structure only for default posts
- Related Posts by Multiple Tags?
- How do I create a link that will always show the latest post?
- strip only specific tags (like ), but keep other tags (like )
- Removing the title attribute from links in the post content
- Post X of Y in single.php / sidebar.php
- How to wrap every image in a post with a div?
- How to have different content in the loop and single
- Single.php Active Category Class
- Paragraphs removed when using get_post_custom()?
- get_post_custom stripping styling issue
- why does HTML Tag not working in Post and Page
- How to add shortcode tags in single.php [closed]
- get_terms parent for current product only
- custom single.php not working
- Content editor creating blank paragraphs in spaces and creating   in the_excerpt
- How to display different single post template based on author?
- Disable single post page
- how to know if the post has pagination () or not
- Remove arrows from previous and next link
- “next_posts_link” and “previous_posts_link” display me NOTHING
- How to disable single post view in wp
- Add scripts on custom post add/edit pages Not Working
- Custom Post Templates
- Pagination on single post page?
- WordPress’ visual editor messing up my (nested) lists (and other things as well)
- Articles are text-only in any “Category” instead of HTML
- Restrict post navigation to current sub menu
- Can’t get the_content of the parent page from its single post?
- Show all posts in sidebar in single.php
- Ajax Dynamic Archives not showing correct results
- How to show single post page as home page
- Using wp_list_categories like the the_category (showing just current categories of a post)
- How can I make a post that belongs to a category or have specific tags, display different from the other single posts?
- Ajaxify This Code
- Pausing and Resuming WP_Query results
- Is Hfeed class for all pages needed
- If in_category not working for multiple single.php pages
- Anyone know why wordpress converts some html entities to their numeric equivalents?
- Single.php – Get Current Parent Category
- Insert sometext after first h3 in content
- Add get_the_tags() to Single Posts section via functions.php
- Is it possible to customize the post according to post format in single.php?
- Multiple comment forms on a single page
- Post type no single page
- Best Way to Add UnEditable HTML to Posts
- Single Post in Tab/Slider
- Divs appearing everywhere in post content
- Benefits to using semantic HTML in post content? [closed]
- HTML Form Submit to table in same page
- get_previous_post() while accounting for sticky posts
- wp-link-pages in header and footer of the post
- Changing wp_link_pages() to “Next Page” and “Previous Page” buttons?
- Attachment image single page
- Nest Next and Previous in a href with class that has a background image
- Locally change the font family [closed]
- WordPress single.php different layouts projects / posts
- Right align a youtube video
- Can I style single post that are in multiple catergories?
- How to save template data into wp_post table (post_content column)
- WordPress – When visiting a `single post/ single.php` my category menu item link becomes active
- How do I change the template specifically for single posts?
- Show single post child category from a determined parent
- WordPress 5: prevent link from displaying page title instead of URL
- out of nowhere
- WordPress Recent Post with the badge “New” on the side of the title post
- WP posts using index.php instead of single.php
- Remove HTML tags from all posts
- How to center all text body in single.php at once?
- Single post shows post three times
- Checking if a post contains an html tag
- How to generate an HTML link automatically from URL in a users’ post
- display multiple posts and posts content on a single URL
- Pagination for single post
- Get the category of post
- Only show related posts when another post has same term
- Adding div to WordPress page content
- List posts of assigned categories in list of all categories on single.php
- Is possible to do this from function.php
- Custom Single Post Type not referring to single-post-type.php File
- Hide Certain Tags on Single Post Page
- Posts don’t appear on Template Page
- Add wp-link-pages to post
- How to get all the terms of a post
- Get current post’s child page?
- 1 post, 2 templates
- Wrap div-tag around posts in page
- Insert Shortcode exactly at the end of the content
- CSS – Change height of Storefront / WooCommerce product categories, but not products
- Wrap posts from a category in HTML
- WordPress More tag doesn’t work on Single post
- No matching template found when using single.php
- how show post date for specific post?
- Show Next/Previous without Link
- How can I add a custom caclulation form in post?
- How to automatically convert a form with HTML link into post
- Posts Page in WordPress loading bare HTML of my homepage