---
url: 'https://www.wpconsults.com/back-to-previous-page-button/'
language: 'en'
title: 'How to Add a Go Back to Previous Page Button in WordPress (2 Easy Methods)'
author:
  name: 'Abdullah Nouman'
  url: 'https://www.wpconsults.com/author/nouman/'
date: '2024-01-05T20:09:40-06:00'
modified: '2026-07-04T23:04:09-05:00'
type: 'post'
categories:
  - 'WordPress Tips &amp; Tutorials'
tags:
  - 'without plugin series'
image: 'https://www.wpconsults.com/wp-content/uploads/2024/01/Write-the-title-of-your-video-here-jpg.webp'
published: true
---

# How to Add a Go Back to Previous Page Button in WordPress (2 Easy Methods)

A go back button gives visitors a one-click way to return to the page they were just on, which is handy on long guides, search results pages, and multi-step checkouts. It is a small touch, but it saves people from hunting for the browser’s back arrow, and on mobile that little bit of friction really adds up.

 

I will show you two easy ways to add one in WordPress: a small HTML snippet that needs no plugin, and a no-code route for people who avoid code. I will also fix the one thing most tutorials skip, what happens when someone lands on the page directly with no history to go back to.

  

### Key Takeaways

 

- A go back button just tells the browser to step back one page in its history, using `history.back()`, which is the same as `history.go(-1)`.
- The reliable way is a small Custom HTML button, with no plugin needed.
- If a visitor arrives directly, there is no history to return to, so add a referrer check that falls back to your homepage.
- The no-code route is a page-builder button or a menu link, though some themes strip javascript links for security.
- A back button is a convenience, not real navigation, so keep breadcrumbs or a clear parent link for crawlers and direct visitors.

  Table of Contents

- What a go back button actually does
- Method 1: a Custom HTML button (no plugin)
- Method 2: a no-code go back button
- Is a back button enough on its own?
- So, which go back button method should you use?
- Update Logs

 

## What a go back button actually does

 

This is not really a WordPress feature; it is a browser one. A go back button calls `history.back()`, which tells the visitor’s browser to return to the previous entry in its own history, exactly as if they had pressed the back arrow ([MDN documents the History API here](https://developer.mozilla.org/en-US/docs/Web/API/History/back)).

 

Because it reads the browser’s history, it always sends people to wherever **they** came from, not a fixed page you choose. That is the strength and the weakness in one line, and it is why the fallback below matters.

 

## Method 1: a Custom HTML button (no plugin)

 

This is the method I actually use, because it is one line, works anywhere you can add HTML, and does not add a plugin you then have to maintain. Drop a **Custom HTML** block where you want the button and paste this:

 

```
<button type="button" onclick="history.back()">← Go Back</button>
```

 

That is the whole button. The catch is direct landings: if someone arrives from Google or a shared link, their history for your site is empty, so `history.back()` either does nothing or bounces them off your site. The fix is to check the referrer first and fall back to your homepage when there is nowhere to go back to ([document.referrer is explained on MDN](https://developer.mozilla.org/en-US/docs/Web/API/Document/referrer)):

 

```
<button type="button" onclick="if (document.referrer) { history.back() } else { window.location.href='/' }">← Go Back</button>
```

 

Use the second version in real projects. It behaves the same for normal visitors, but it never leaves a direct-landing visitor stuck on a button that does nothing, which is a far better experience for the exact people search sends you.

 

## Method 2: a no-code go back button

 

If you would rather not touch HTML at all, most page builders can do this for you. In a builder like Kadence, add a Button element and set its link to `javascript:history.back()`, and you get the same behavior from a visual editor, with the same kind of option in most other builders.

 

People often try to add it as a menu Custom Link instead, and that can work, but be warned: WordPress sanitises `javascript:` links in menus on many setups, so it silently does nothing. If the menu route fails on you, fall back to the Custom HTML block from Method 1, or a small single-purpose back-button plugin as a last resort.

 

| Method | How it works | Best for | Watch out for |
| --- | --- | --- | --- |
| **Custom HTML button** | A one-line button running history.back() in a Custom HTML block | Anyone comfortable pasting one line | Add the referrer fallback for direct landings |
| **No-code (builder or menu)** | A page-builder button or menu link set to go back | Non-coders on a page builder | Menus often strip javascript links, so the button does nothing |

The two ways to add a go back button in WordPress, and the catch to watch for with each. 

## Is a back button enough on its own?

 

A go back button is a nice convenience, and I am glad to add one, but it should sit on top of proper navigation rather than stand in for it. Search crawlers never click it, and direct-landing visitors have no history for it to use, so those readers still need a real way around your site.

 

Keep a clear parent or category link and, ideally, breadcrumbs so everyone can move up a level with a genuine URL. Do that and the back button becomes a pleasant extra, which is exactly what it should be. If a floating version of this button ever clashes with a corner widget, my guide on [moving the reCAPTCHA v3 badge](https://www.wpconsults.com/how-to-move-recaptcha-v3-badge-to-left-in-wordpress/) shows the same kind of fix, and for other hands-on tweaks see my walkthroughs on [customizing the WordPress login page](https://www.wpconsults.com/customize-wordpress-login-page-manually/) and [changing the wp-admin URL without a plugin](https://www.wpconsults.com/change-wp-admin-url-without-plugin/).

 

## So, which go back button method should you use?

 

If this were my site, I would reach for Method 1 with the referrer fallback, because it is one line, adds no plugin, and quietly handles the direct-landing case that trips up the basic version. It is the cleanest option for anyone who can paste a snippet into a Custom HTML block.

 

That said, the no-code route is a perfectly good call if you never touch code; a page-builder button does the same job from a visual editor. Either way, add the fallback thinking, keep real navigation in place, and the button will help rather than frustrate.

  

### Still stuck adding your go back button?

 

If the button will not behave or you want it wired up cleanly across your theme, feel free to [contact us](https://www.wpconsults.com/work-with-wpconsults/) or [email me](mailto:abdullah@wpconsults.com) and I will happily point you in the right direction.

   

## Update Logs

 

**02 Jul 2026**

 

- Rewrote with a reliable no-plugin button, added a referrer fallback so it still works when someone lands directly, and clarified when to lean on real navigation instead.
- Sharpened the section headings so each is clear on its own.
