Anchor based links in multi-page posts
-
If I split a post into multiple pages, via “<!–nextpage–>”, what is the best way to provide links to content that may be split on a different page?
Usually, I would use an HTML anchor, but if a page break is used then obviously the anchors also need to be qualified with the page address. I can code this from the permalink, but this seems terribly fragile…
The blog I need help with is: (visible only to logged in users)
-
Have your read this support doc? https://en.support.wordpress.com/splitting-content/nextpage/
Note the display on that page of the page numbers as that will be the result on your blog ie. the software does this for you. -
Yes – I understood that and it works.
What I want to do is slightly different – I want to add some links within the main text to act as short-cuts to other content within the post.
With a single page, I can just add #anchor links – but obviously this will not work if the post is split in to several pages.
The only option I can think of is to hard-code the final page address, so something like: “http://blog.com/post?page=2/#anchor”. Unfortunately, this hard-codes the page numbers, making it “brittle” to any content changes…
-
Then you want to create anchor links AKA page jump links instead of using pagination (next page).
To use page jump links see:
http://wpbtips.wordpress.com/2010/08/01/links-to-specific-points-on-a-page/
http://en.support.wordpress.com/splitting-content/page-jumps/ -
Yes, but these are very basic and none address the question that I am asking – namely how to link to the auto-generated URLs that result from pagination.
-
Then please type modlook into the sidebar tags on this thread for Staff help. How do I get a Moderator/Staff reply for my question? https://en.support.wordpress.com/getting-help-in-the-forums/#how-do-i-get-a-moderatorstaff-reply-for-my-question Then please subscribe to this thread so you are notified when they respond. To subscribe look in the sidebar of this thread, find the subscribe to topics link and click it.
-
Did you actually click the numbered page links on this page?
https://en.support.wordpress.com/splitting-content/nextpage/
2
3 -
Yes – but the links are hardcoded.
This is a very long post, and should probably be split in to 5 or 6 pages. When adding the #anchor tags, it is very hard to know what the page number is, as to link I need to use the page address qualified by page number and anchor name.
What I need is some means (from within wordpress) to automatically generate those links. ie: I really want just to code things link … and have WordPress automatically update the link’s URL based on the address (page number) that the anchor turns out to be on.
If you can not do this automatically, creating internal links in a long, paginated post is extremely painful (and error prone!).
-
Example of URL of post
https://en.support.wordpress.com/splitting-content/nextpage/
URL of page 2 of that post
https://en.support.wordpress.com/splitting-content/nextpage/2/Please be patient while waiting for Staff help.
-
Neither of these examples reference an anchor placed in the original post (before pagination). You have to somehow know the page number (and re-edit all internal links if you ever add another page break).
-
Hi @transienteye, can you link to the post you’re working on? Seeing it will give us more context to help.
-
It is here: http://transienteye.com/2015/09/05/capture-one-pro-8-3-2-review/
The original intent was simply to ease bandwidth and load times – the article is ~10k words and contains more than 50 large images.
The problem is with how to insert links, such as those in the first couple of paragraphs, that reference anchors on subsequent pages. The “next page” links at the bottom are also manual – added because the idiotic theme has by default placed the page selectors *after* the sharing and related links!
I can do this by hard-coding the link URL and page number, but with a long post it quickly becomes unmanageable to do this – particularly if you change the number of pages. Worse still, the hard-coded URLs are different for the preview and the published post – so you can not sensibly check such links before the post is published.
This is the first time that I have tried to use pagination in a blog post, but it has been so painful that I really can not see doing this again in future.
I may strip out the pagination in the link later today, to resolve the idiotic theme quirks…
-
Thanks, that helps.
If you’re keeping the pages and you aren’t going to be changing the number of pages later, you can add links to sections like so:
http://transienteye.com/2015/09/05/capture-one-pro-8-3-2-review/3/#linkedsectionThese would not be fragile, so long as you don’t change page numbers later. Let us know if you need help setting that up.
If you do want to be able to add more pages as you’d like, which would cause the page numbers in your links to change, you would probably be better off using more permanent links. Individual pages and individual posts each have permalinks. So you might consider making this a series of posts within one tag or category, or you could make child pages within a parent page. Personally, I would go with individual posts within Reviews > Capture One .
I hope that helps!
- The topic ‘Anchor based links in multi-page posts’ is closed to new replies.