WordPress Tutorials

    Add META Tags to WordPress Head
    The reason that WordPress is so developer-friendly is their awesome hook system.  Depending on a post category (or seemingly anything else), you can modify the contents of the page, the theme templates, and everything else.  WordPress is amazing. One recent use case I had was wanting to modify the tag based on […] The post Add META Tags to WordPress Head app […]

    WordPress Publish Post Hook
    One of the best parts of WordPress is its hook/action system; this special hook system is WordPress' way of assigning callbacks when certain events occur. One event that there seems to be a lot of confusion over is which hook to use to detect when a post is initially published. There's the publish_post hook but […] The post WordPress Publish Post H […]

    Using DOMDocument to Modify HTML with PHP
    One of the first things you learn when wanting to implement a service worker on a website is that the site requires SSL (an https address).  Ever since I saw the blinding speed service workers can provide a website, I’ve been obsessed with readying my site for SSL.  Enforcing SSL with .htaccess was easy — the hard […] The post Using DOMDocument to Modify HTM […]

    Add Custom CSS to WordPress Admin
    Believe it or not, I spend an awful lot of time going through my blog’s comments and correcting spelling issues, code formatting, etc.; yes, even the comments from way back to 2007.  It’s mostly for quality control purposes and ease of reading for my readers, especially the code comments. One gripe I have with WordPress’ admin section […] The post Add Custom […]

    Prevent WordPress from Loading “Next” Pages
    I’ve been working to make this blog more performant by lazy loading everything I can think of, placing CSS and JavaScript into the HTML, and using data URIs;  the common theme in these is reducing the number of requests on each page.  One request I noticed (and hadn’t anticipated) coming from WordPress looked like this: WordPress […] The post Prevent WordPre […]

    Serve a Directory with PHP
    Many developers have a giggle at PHP, even looking down at the language, but let’s be honest:  most of our blogs are powered by it (WordPress) and it’s a great language to dabble around with.  I cut my teeth on PHP, though I prefer to avoid PHP these days. But when I need to experiment with a simple […] The post Serve a Directory with PHP appeared first on D […]

    Improving WordPress Commenting with Postmatic
    We’ve set out to create a fantastic commenting plugin for WordPress. It’s called Postmatic and what it does is a first for any blogging system: to allow synchronous 100% email and web-based commenting. The web folks can engage via the web. The email folks can stick to email. And everyone can remain focused, engaged, and […] The post Improving WordPress Comme […]

    Preventing Bot Attacks on WordPress using No Captcha reCaptcha
    There are many different solutions to prevent bots from submitting web forms; one of the most popular solutions is reCaptcha. reCaptcha actually displays an image with some text in it and user has to enter the text to submit the form successfully. It was difficult for bots to read the text on the image, but […] The post Preventing Bot Attacks on WordPress us […]

    Add a Submenu to the WordPress Admin Bar
    A while back I wrote Add Menu Items to the WordPress Admin Menu, a post detailing how you can add items to the left side, existing “posts” menu bar.  Adding menu items has served me well but it’s not as customized as I would like — I’m still adapting to WordPress instead of WordPress adapting to […] The post Add a Submenu to the WordPress Admin Bar appeared […]

    Over the past four or so months, I’ve been having a hell of a time with seeing 500 errors on my site.  And while I’m on my site a few hours a day, the amount of 500s my visitors must have seem is probably huge.  And that’s a problem.  A big, annoying problem.  The following details […] The post 500 appeared first on David Walsh Blog.

    Append and Prepend to WordPress RSS Feed Content
    The awesome part of RSS is that it lets you pull content wherever you want.  The bad part, as a publisher, is that the user may be missing out on important information that is on the site but doesn’t display in articles.  WordPress’ hook system to the rescue! The PHP We’re going to hook onto the the_content and the_excerpt_rss function […] The post Append an […]

    Preprocess Comment Content in WordPress
    I’ve put a great amount of effort into making sure the comment system on this blog is fast and feature-filled.  The comment system is AJAX-based so you don’t need to worry about page refreshes.  You can also post links to GitHub gists, CodePen pens, and JSFiddle fiddles and see them rendered within the comment.  Those tasks I […] The post Preprocess Comment […]

    How I Stopped WordPress Comment Spam
    I love almost every part of being a tech blogger:  learning, preaching, bantering, researching.  The one part about blogging that I absolutely loathe:  dealing with SPAM comments.  For the past two years, my blog has registered 8,000+ SPAM comments per day.  PER DAY.  Bloating my database with that trash slows down my blog in every […] The post How I Stopped […]

    Prepend and Append Text to WordPress Titles
    I was thinking about little ways to improve my blog and one small enhancement I wanted to make was adding more information to post titles when they show up in RSS feeds.  Something about notifying the user via title outside of the site itself seemed like a good idea.  For example, some posts are just small “quick […] The post Prepend and Append Text to WordP […]

    Remove WordPress Admin Bar CSS
    A version or two back, WordPress decided to add a toolbar for logged in users on the display side that’s about the site’s theme.  I get why they did it but it’s an annoyance to me — I don’t care to see it.  To accomplish this task, WordPress injects the following into every page:

    Add Menu Items to the WordPress Admin Menu
    The existing menus in WordPress are solid but one annoyance is that I need to click “All Posts” and then the “Drafts” link to get to my drafts; I simply want to get there as quickly as possible via the Posts menu. I did some quick research on the topic and in two minutes I […] The post Add Menu Items to the WordPress Admin Menu appeared first on David Walsh […]

    Pygments on PHP & WordPress
    I’ve been in a long journey trying to find a great code highlighter, I’ve been using a lot of them that I can’t even remember. These are the ones I can remember right now: SyntaxHighlighter Google Prettifier highlighter.js Geshi Right now I’m using highlighter.js but it wasn’t exactly what I want, what I want is […] The post Pygments on PHP & WordPress a […]

    Sort Objects by Property with PHP
    I recently needed to display a list of authors within a WordPress blog.  The goal was to sort the author list by number of posts before outputting the list.  The method for calculating number of posts isn’t a sortable key within WordPress’ get_posts, so I had to sort the result list myself.  PHP’s usort method, […] The post Sort Objects by Property with PHP […]

    Add and Remove Profile Fields to WordPress User Form
    The WordPress user profile screen allows you to set values for social services but some default services are irrelevant, namely AIM and Yahoo! IM;  add to that the fact that Twitter and Facebook fields are missing.  You quickly realize that the default form…needs work.  WordPress provides a method for adding and removing profile fields.  Let […] The post Add […]

    Create WordPress Shortcodes
    WordPress shortcodes are super handy, especially when handing off a WordPress-based website to a client. The alternative to using shortcodes is creating complicated templates, and even then, you cannot adequately replace what shortcodes can do. I recently needed to implement a new shortcode for the Mozilla Hacks blog and was happy to learn how simple […] The […]