PHP Tutorials

  • By
    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...

  • By
    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...

  • By
    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...

  • By
    Override WordPress URL

    When I migrated my website between Media Temple servers, I wanted to manually test the site to ensure no server configuration differences between the server were bricking the site.  The obvious problem I would encounter is that links would be broken because the site wasn't...

  • By
    Remove HTML Comments with PHP

    When it comes to sending content to users, I'm of the belief that less is more.  There's no reason for HTML comments to be sent down to the user -- they simply bloat the payload.  I remove unwanted HTML comments within my WordPress theme, so I...

  • By
    Allow More HTML Tags in WordPress Comments

    WordPress allows a select few HTML tags within the content of post comments.  This is an awesome feature, of course, because it prevents XSS security holes and other malicious code from being injected by spammers, hackers, and jerks.  Unfortunately there are many other tags that bloggers...

  • By
    Gist Shortcode Embed

    Blog comments and forum posts are traditionally the worst place to post code, but unfortunately are the frequent hosts of code for developers like us.  Many developers choose to post links to more dev-friendly environments like GitHub instead, but there's a certain disconnect that comes with...

  • By
    Xbox Live Gamer API

    My sharpshooter status aside, I've always been surprised upset that Microsoft has never provided an API for the vast amount of information about users, the games they play, and statistics within the games. Namely, I'd like to publicly shame every n00b I've baptized with my...

  • By
    Add META Tags, Scripts, and Stylesheets to the WordPress Header and Footer

    There are times where you may want to conditionally inject stylesheets or scripts into your header or footer, or you'd simply prefer to inject those resources via PHP instead of place the HTML in template files directly.  WordPress' ever-powerful add_filter function provides the a method for...

  • By
    Force SSL with WordPress

    WordPress, the popular blogging CMS platform, is used as an all-purpose site software these days.  The difficulty in using all-purposes solutions is that they are often difficult to customize when edge cases pop up;  one of those edge cases can be forcing SSL.  Many form pages...