WordPress Dynamically Write Number of Years Since With Shortcode

As the lengthy title says, the follow simple script allows you to use a shortcode to dynamically output the number of years since a specified date. I wrote this for my own bio, which I used to have to update the number of years since the start of my employment once a year. The simple’r solution would be to write, “blah blah blah since 2010” instead of “blah blah blah for 7 years“. But hey, why not.

Simple usage is []years since="2010-07-01"[] would output something like 7.

WordPress Display MarkDown ReadMe File With Shortcode

For demo/home sites of a theme/plugin that wish to include the projects main readme files as part of the website, this quick snippet loads the folders README.md file, and parses the MarkDown (to githubs flavour) with a awesome jQuery plugin, all with the simple call of a [readme] shortcode.

Add All Super Admins To All Sites On WordPress

One of the most annoying features of WordPress Multisites (besides domain mapping) is adding a Super Admin a few years after your network is established and grown. Sure, being a Super Admin allows said user to access any site on the network, but the user is technically not added to the site – so the Super Admins users My Sites tab will only have sites that s/he has been manually added to. The user is then forced to jump between sites with a headache of manually typing.

The follow script solves the problem, it runs through all super admins and adds them to all sites in the network they’re not yet added to.

The function needs to be run once to get everyone up to date. For the future it can be wrapped in a $_GET conditional to fire manually, a cronjob to run in background, or like I did, a transient, so that you can run it as often as you need. Mind you this isn’t a network plugin or intended to run on all sites, it just needs to run once on a single site. All the multisite data and blog_switching annoyance happens within the functions themselves.

WordPress Troubleshooting 101

I’m a semi-regular contributor on WordPress Support Forums. & as you develop and assist more, you realize that theres a basic troubleshooting routine to solve almost all vague/inexplicable problems – you typically do the same things. These problems include;

  • /wp-admin/ not loading
  • Unable to drag and drop in dashboard
  • White screen instead of site
  • Unable to use Visual tab

Basically anything not normal or anything not working properly (that is not directly related to installing or using a new plugin. To get your WordPress site back online, here’s a breakdown of how to troubleshoot to find the issue:

  1. Visit your error log to reveal PHP errors
  2. Turn wp_DEBUG on to reveal MySQL + PHP errors on your WordPress site
  3. Disable all plugins one-by-one to find the culprit
  4. Disable your theme, revert to Twenty-x
  5. Upload WordPress to fix any permissions or file errors (except /wp-content/ and wp-config.php)
  6. Comment out any .htaccess firewalls or non-WordPress rewrites

If any of these techniques work, refer to basic Google’ing on how to resolve the issue. Open source software controlling 25% of the web, the odds are in your favour that someone experienced it too and wrote about it.

For overly basic example; if you discover plugin FooBar was not allowing drag and drop to work in the backend, search “WordPress FooBar drag and drop not working” – and you should find your answer.

Doing the troubleshooting in the order should eliminate any “I know it‘s my theme, but I don’t know what’s not working” issues, your problem will likely spit out in PHP errors.