Support » Developing with WordPress » Link to archive page on single post

  • Resolved Indent


    My blog archive is paginated and I want a link on single posts back to the archive parent page.

    I have this and it’s working, sort of…

    function back_to_parent_archive() {
    	$url = htmlspecialchars($_SERVER['HTTP_REFERER']);
    	echo "<p><a href='$url'>Back to main page</a></p>";

    The problem is if you’re on a single post and start using next/previous navigation between posts, because the above function is essentially a browser back button.

    So, is it possible to generate a link back to parent archive page regardless of which post you’re on?


Viewing 5 replies - 1 through 5 (of 5 total)
  • There are so many different kinds of archive pages. How would you know which one to use, and which part of the archive? (category, tag, author, month, day, latest are all archive pages with multiple “pages” of posts)
    It’s best just to use the normal links to categories and tags and then widgets with other archive types.

    I agree, but in my case there is only one category and one type of posts. So all posts are the same but spread out on multiple archive pages.

    My thought was that WP posts would have a dynamic link to its parent archive page since the post location on a paginated archive is shifting when you add new posts to the archive. Does that make sense? How to retrieve that URL if at all possible?

    Sorry, what I mean is the paginated blog index, NOT the archive, which I don’t use BTW. Don’t know if that makes a difference?

    No, it doesn’t make sense, because it is always changing as you add posts.
    Even if you don’t use the other archives, they still exist and any user can go to those pages (author, category, latest, month, day)
    They can always hit the back button, and use the menu to get to where you want them to go.

    OK, thanks for your time.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Link to archive page on single post’ is closed to new replies.