0

My post content looks like this

<img src="http://linktoimage.jpg" alt=""/>
<!--nextpage-->
<img src="http://linktoimage.jpg" alt=""/>
<!--nextpage-->
<img src="http://linktoimage.jpg" alt=""/>
<!--nextpage-->

Basically I'm trying to make a web comic book so I have made each image to split onto multiple pages using the <!--nextpage--> feature. Now the problem is I want my images to be linked to the next paginated post. I can't use <?php wp_link_pages(); ?> to make a hyperlink on the image cause wp_link_pages outputs it as html and I need it as raw url and I don't need prev & next link. I only need a next link on the image.

Is this a way to make my images to be hyperlinked to the next paginated post?

2

1 Answer 1

0

If you take a look at the link generated by the <!--nextpage--> tag, it just appends /2 for page 2 /3 for page 3 and so on. In other words, it adds a query string page=page_number to your post link.

So all you have to do is insert an hyperlink to your image with the next page number for that image.

you still need to add the <!--nextpage--> tag because that will break your post in multiple pages. If you don't all your images will all appear on each paginated page.

3
  • Is there a template tag that I could use to apply to my template file? instead of me manually linking the images
    – Ruriko
    Commented Aug 14, 2016 at 3:40
  • Well not really, since your images are on a text editor (the post content) there is no way to get to those images and knowing what is what. You would need to use some sort of custom post type with relevant taxonomy to link each images together in the order that would make sense to you or maybe make use of custom field on the post but then again that last suggestion would become messy quite rapidly since you would need to provide each image URL, and the order of each of these images so we could programmatically order the output
    – bynicolas
    Commented Aug 14, 2016 at 4:20
  • actually, there might be a way, but it would involve targeting and updating your links through jQuery. But I don't think that would be a good approach for your use case.
    – bynicolas
    Commented Aug 14, 2016 at 4:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.