{"id":54458,"date":"2017-08-28T19:27:01","date_gmt":"2017-08-28T22:27:01","guid":{"rendered":"https:\/\/wiki.samuelchopard.ch\/?p=54458"},"modified":"2019-03-18T14:29:19","modified_gmt":"2019-03-18T13:29:19","slug":"go-back-link-in-php","status":"publish","type":"post","link":"https:\/\/samuelchopard.ch\/wiki\/library\/go-back-link-in-php\/","title":{"rendered":"&#8220;Go Back&#8221; link in PHP"},"content":{"rendered":"<p><!--more--><\/p>\n<p>This code is useful if you need to use a &#8220;Go Back&#8221; (to last page) button\/link in a page template of your theme.<\/p>\n<p>To add the code, copy the page template from your theme and paste it in your <a target=\"_blank\" href=\"https:\/\/samuelchopard.ch\/wiki\/library\/download-blank-child-theme\/\" target=\"_blank\" rel=\"noopener noreferrer\">child-theme<\/a>. Then, edit the copied file.<\/p>\n<p>Where you want to add the link, past the following code:<\/p>\n<pre class=\"EnlighterJSRAW\">$url = htmlspecialchars($_SERVER['HTTP_REFERER']);\necho \"&lt;a target=\"_blank\" href='$url'&gt;back&lt;\/a&gt;\";<\/pre>\n<p><strong>Note:<\/strong> replace &#8220;back&#8221; with the text that suits you.<\/p>\n<p>&nbsp;<\/p>\n<p>Source:\u00a0<a target=\"_blank\" href=\"https:\/\/css-tricks.com\/snippets\/javascript\/go-back-button\/\" target=\"_blank\" rel=\"noopener noreferrer\">https:\/\/css-tricks.com\/snippets\/javascript\/go-back-button\/<\/a><\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"This code is useful if you need to use a \"Go Back\" (to last page) button\/link in a page template [...]","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[10,3,5],"tags":[118,154,160],"class_list":["post-54458","post","type-post","status-publish","format-standard","hentry","category-child-themes","category-php-tricks","category-themes","tag-go-back","tag-last-page","tag-link"],"_links":{"self":[{"href":"https:\/\/samuelchopard.ch\/wiki\/wp-json\/wp\/v2\/posts\/54458","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/samuelchopard.ch\/wiki\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/samuelchopard.ch\/wiki\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/samuelchopard.ch\/wiki\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/samuelchopard.ch\/wiki\/wp-json\/wp\/v2\/comments?post=54458"}],"version-history":[{"count":1,"href":"https:\/\/samuelchopard.ch\/wiki\/wp-json\/wp\/v2\/posts\/54458\/revisions"}],"predecessor-version":[{"id":54862,"href":"https:\/\/samuelchopard.ch\/wiki\/wp-json\/wp\/v2\/posts\/54458\/revisions\/54862"}],"wp:attachment":[{"href":"https:\/\/samuelchopard.ch\/wiki\/wp-json\/wp\/v2\/media?parent=54458"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/samuelchopard.ch\/wiki\/wp-json\/wp\/v2\/categories?post=54458"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/samuelchopard.ch\/wiki\/wp-json\/wp\/v2\/tags?post=54458"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}