Category:

For a while now I’ve wished there was a better way to find other people who self-host WordPress. On the one hand, it’s not that hard. If you find someone’s personal blog, chances are it’s running on WordPress. On the other hand, where do you start?

I found a couple of blog directories and so I’m going to begin browsing those from time to time and then I can add interesting blogs to my blog directory. But, I want this directory to only be WordPress-powered blogs.

But, how can I quickly detect if a blog uses WordPress? While there may not be a foolproof way, there is a way that is likely 99% effective. I took the ways I’ve learned and put them into a bookmarklet.

Copy the code below, and paste it as the URL in a new browser bookmark. Then, when you are on a website and you want to know if it runs WordPress or not, click the bookmark.

javascript:(function(){var t=!1;if(-1!==window.location.href.indexOf("wp-content")||-1!==window.location.href.indexOf("wp-includes")||-1!==document.documentElement.innerHTML.indexOf("wp-content")||-1!==document.documentElement.innerHTML.indexOf("wp-includes"))t=!0;var e=document.getElementsByTagName("meta");for(var i=0;i<e.length;i++){var n=e[i].getAttribute("content"),o=e[i].getAttribute("name");if(n&&n.toLowerCase().indexOf("wordpress")!==-1||o&&o.toLowerCase().indexOf("generator")!==-1&&n&&n.toLowerCase().indexOf("wordpress")!==-1){t=!0;break}}var a=document.querySelectorAll(".wp-block,.wp-caption,.wp-caption-text,.wp-post-image,.wp-post-thumbnail,.wp-video-shortcode");a.length>0&&(t=!0);alert(t?"This website is likely running on WordPress.":"This website is not running on WordPress.")})();

Let’s unpack the minimized code. Below is an easier-to-read version with comments. But, use the above version for your bookmark.

javascript:(function() {
  var isWordPress = false;

  // Check if wp-content is present in the URL
  if (window.location.href.indexOf('wp-content') !== -1) {
    isWordPress = true;
  }

  // Check if wp-includes is present in the URL
  if (window.location.href.indexOf('wp-includes') !== -1) {
    isWordPress = true;
  }

  // Check if wp-content is present in the HTML source
  var htmlSource = document.documentElement.innerHTML;
  if (htmlSource.indexOf('wp-content') !== -1) {
    isWordPress = true;
  }

  // Check if wp-includes is present in the HTML source
  if (htmlSource.indexOf('wp-includes') !== -1) {
    isWordPress = true;
  }

  // Check for meta tags mentioning WordPress (case-insensitive)
  var metaTags = document.getElementsByTagName('meta');
  for (var i = 0; i < metaTags.length; i++) {
    var content = metaTags[i].getAttribute('content');
    var name = metaTags[i].getAttribute('name');
    if (content && content.toLowerCase().indexOf('wordpress') !== -1) {
      isWordPress = true;
      break;
    }
    if (name && name.toLowerCase().indexOf('generator') !== -1 && content && content.toLowerCase().indexOf('wordpress') !== -1) {
      isWordPress = true;
      break;
    }
  }

  // Check for common WordPress CSS classes
  var cssClasses = document.querySelectorAll('.wp-block, .wp-caption, .wp-caption-text, .wp-post-image, .wp-post-thumbnail, .wp-video-shortcode');
  if (cssClasses.length > 0) {
    isWordPress = true;
  }

  // Display the result in a popup
  var message = isWordPress ? 'This website is likely running on WordPress.' : 'This website is not running on WordPress.';
  alert(message);
})();


Leave a Reply

Your email address will not be published. Required fields are marked *

Billy Wilcosky