Web development and useful information

WordPress Bookmarklets

Here’s some handy bookmarklets I use while building WordPress websites.

Edit the current post

javascript:(function() { const pageid = Array.from(document.body.classList).filter(function(item) { return item.includes("page-id-"); });
const id = (pageid.length > 0) ? pageid[0].replace("page-id-", "") : 0; if (!id) { alert("No WordPress post found"); } else {  document.location = document.location.origin + "/wp-admin/post.php?&action=edit&post=" + id; } })();

This next one is a modified Nat Taylor’s bookmarklet. It’s modified to skip visiting the login page if you’re already logged in. WP will send you to the login page if you’re not logged in.

This is handy when the WordPress admin bar is hidden.

Go to WP admin / login page

javascript:window.location.href = `${window.location.protocol}//${window.location.hostname}/wp-admin`;

Go to the Site Health admin page

javascript:window.location.href = `${window.location.protocol}//${window.location.hostname}/wp-admin/site-health.php?tab=debug`;

How to use

Add a new bookmark in your browser, paste the JavaScript code into the URL field and give it a meaningful name.

I name mine wp-E (WordPress Edit) and wp-L to save space on my bookmarks bar

Have a nice bookmarklet you use for WordPress development? Share it below in the comments.

Previous

Allow Create and Update feeds with the Gravity Forms User Registration Add-On plugin

Next

How to use the CoinSpot API V2 in Postman

2 Comments

  1. N

    Hi,

    I tried the “Edit the current post/page” bookmarklet in both Firefox and Brave, but it doesn’t appear to do anything in either.

    • Hey N, you’re right, thanks!

      Tried it, didn’t work on a WP homepage, but worked on a contact page.

      I updated the snippet with something that works on all pages I tested it on.
      Also now shows an alert if a post ID can’t be found (not a WordPress site).

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Powered by WordPress & Theme by Anders Norén