Back button to previous page and breadcrumbs

For the button behavior,

If it’s a one-off use case, you could add custom php conditional to check the referring url $_SERVER[‘HTTP_REFERER’] and current page/post ID or url. Then, either add a class to the button’s containing div wrapper in the template for hiding via css or directly output/include the button html in the template file itself.

If it applies for various cases, I’d recommend creating an array of 2-d arrays (referrer url or post id, target url or post id). Then use (setting/checking) a session cookie to loop through the array to see if any conditions are satisfied and in turn, show or hide button