Software Engineering in WordPress, PHP, and Backend Development

Category: Tips (Page 5 of 10)

Various articles covering anything from how to programmatically achieve a certain task to useful ways that I’ve found to manage my time.

HTML Code Styles: What Are Your Strategies?

I've written a follow up post to this article that you can read here.

Personally, I’m a big fan of implementing coding standards and/or style guides for each of our various languages. Ultimately, I think that it helps to make a team’s code more readable and maintainable.

On one hand, some developers are better at adopting said standards than others, whereas other developers enjoying helping to write the documentation, books, and pull requests to make sure code is up to the given standard.

Although I’m personally a big fan of coding standards, there’s always room for small improvements in each language that help optimize a developer’s work flow.

As such, I thought I’d share two things that I do as part of my HTML code styles that help make code more readable and improve the workflow in my IDE.

Continue reading

Change the Email Sender in WordPress

If you're an experienced developer, you can skip to the code by clicking here.

If you’re in the business of hosting WordPress-based sites or at least managing WordPress-based sites, then it’s likely that you’re also responsible for managing email accounts or how email is relayed from the site and the server to its visitors.

And depending on the nature of your setup, this may not be a problem; however, if you’re operating on some type of hosted solution, some type of managed hosting, or aren’t using a third-party solution such as Google Apps, then there’s a chance that site visitors are receiving emails from their favorite WordPress-based site with incorrect or unclear email sender information.

Case in point: I manage a site where comment notification emails were being sent with the following formation:

[ Site Name ] [My Email Address] via [Server Name ]

Obviously, this is okay if it’s my site, but a client’s site? Negative.

Continue reading

Quick Tip: Including jQuery in WordPress The Right Way

Much has been said on the subject of properly registering and enqueueing scripts in WordPress, so I hate to write yet another “including jQuery in WordPress the right way” post, so I’ll attempt to cover it from a different angle.

Because jQuery ships with WordPress, it’s really just a simple matter of making sure you call:

wp_enqueue_script( 'jquery' );

In your functions.php file.

But that’s really only half of it. After that, you have a matter of actually setting up your JavaScript source.

Continue reading

Quick Tip: Disable Comments Programmatically

If you're an experienced WordPress Developer, then skip down to the code.

I’ve been working on small site that’s serving as a digital storefront for a company. The requirements have called for the homepage to feature a variety of featured projects, a news feed, and similar features all of which are obviously custom queries.

There’s a unique feature to this particular project around the newsfeed that’s a bit atypical for other blogs. That is, the project calls for comments and pings to be disabled.

If you find yourself in a similar situation, here’s a quick tip for how you can disable comments programmatically and how you can disable pings programmatically.

Continue reading

Using WP_User_Query To Retrieve Users Across Multiple Roles

I’ve covered WP_User_Query in a previous post. In short, WP_User_Query is the preferred method for retrieving user information from the database when working with custom queries.

One of the shortcomings of this API method is that it doesn’t allow you to query across multiple roles. So, for example, if you want to retrieve users that meet a certain criteria but may span across multiple roles – say editors and administrators – the API doesn’t support it.

That said, there is a simple strategy that can be used with WP_User_Query to retrieve users across multiple roles.

Continue reading

« Older posts Newer posts »

© 2025 Tom McFarlin

Theme by Anders NorenUp ↑