• Resolved rgbk

    (@rgbk)


    I just can’t believe this question has never been asked.

    Even google does not know what I’m talking about, yet it’s so normal a thing to have. Honestly I’ve tried *everything*, the entire evening. Nada, Nothin.

    All i want is a contextual back button.

    A bit like a breadcrumb, but not.

    Like i was on page x, i clicked on a link, whatever that may have been, and it says on the new page, go back to ‘x’

    Every WordPress breadcrumb plugin sux, because none of them regard the fact that some posts have multiple categories. So it just takes the lowest id numbered category as the pervious path (?!?!?) which is just complete BS.

    Please tell me something like this is possible?!

    There must be a way to catch the previous page and reference it in the next page.

    Put it this way, somehow ‘previous_post_link’ and ‘next_post_link’ has contextual awareness, so surely there’s a way to do this?

    I’m just amazed that this problem hasn’t been a bigger issue. Breadcrumbs go through category paths, and people do use multiple categories for non-blog style sites (ie creative portfolios).

    (help!)

Viewing 5 replies - 1 through 5 (of 5 total)
  • <?php
    if ($post->post_parent) {
       echo '<a href="'.get_permalink($post->post_parent).'" class="back">Back to '. ucwords(get_the_title($post->post_parent)) .'</a>';
    } ?>
    Thread Starter rgbk

    (@rgbk)

    @ianatkins: that didn’t work for me but maybe becasue i didnt know how to implement it. No results where erratic if i removed the ‘if’ statement and not shown if i left it on.

    @alchymyth: i searched the forums for this function and found this:

    $my_referrer = wp_get_referer();
    if( $my_referrer ) {
    	echo 'The referrer is: ' . $my_referrer;
    }

    Which seems to work! Just need to strip the url.

    I’ll show you my final code in a bit.

    Thread Starter rgbk

    (@rgbk)

    Guys
    This is the solution:

    <?php
    $url = wp_get_referer();
    $path_parts = pathinfo($url);
    echo 'Back to '. $path_parts['filename'], "\n";
    ?>

    Pretty elegant solution!

    Thanks a bunch alchymyth

    Just to clarify, my code has to be used in the loop. And links back to the parent page of a sub page. (wrong end of the stick!!)

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Asking for the impossible? A Contextual Back Button (ie: Back to 'x')’ is closed to new replies.