Software Engineering in WordPress, PHP, and Backend Development

Author: Tom (Page 389 of 427)

Programmatically Create a Post in WordPress

If you're an advanced developer or just want the TL;DR version of this, skip to the code.

Create a Post in WordPress

For many, creating WordPress posts and pages is a simple matter of using the built-in editor. But if you’re working on a more advanced project – perhaps you need to automatically generate pages (or posts) to act as views or to restrict users from accessing the dashboard.

If that’s the case, then it may be better to programmatically create a post in WordPress.

Case in point: I’ve been working on a project where all user profile management (save for administrators) has to occur outside of the dashboard. This means that when the theme is installed, it needs to automatically generate pages that support this functionality.

It’s not terribly difficult, but it’s important to make sure that you aren’t overwriting existing pages, that you’re properly setting post attributes, and that you’re properly assigning templates when necessary.

Here’s a simple example of how to programmatically create a post in WordPress.

Continue reading

Why WordPress Isn’t Viewed as an Application Framework

WordPress Application Framework

When using frameworks like .NET or Rails, it’s easy to demonstrate how said frameworks were used to build a piece of software. But because of the nature of WordPress, it’s far more likely that people are to treat any project as either a blog or a site powered by a CMS.

In some cases, that’s true; but it’s not a hard and fast rule. Blogs and sites are just two examples of things are can be built (and, honestly, are the most typically built) with WordPress but they aren’t the only things.

I’ve shared my thoughts on using WordPress as a framework for web application development, but this still raises the question: if WordPress is a framework, then what is the software?

Continue reading

Tips For Securing WordPress

I think that the general consensus is that WordPress is a secure platform – and in many ways, it is – but the truth is that it’s still software and that there will inevitably be bugs.

On top of that, if you’re in the business of building products – sites, themes, plugins, etc – on top of WordPress for others, then ultimately you – not the platform – become responsible for anything that goes wrong with the application or any security that arises.

But how do we know we’ve taken taken the necessary steps to make our work as secure as possible?

Continue reading

Programmatically Create a User in WordPress

If you're an advanced developer or just want the TL;DR version of this, skip to the code.

When it comes to building a certain type of web app, I obviously think that WordPress is a viable option. Out of all of the contract work I’ve done in the past couple of years, about half of the projects have required some form of user management.

That is, they usually want users to create their own accounts, set a few fields such as their name and email address, and then be emailed when all is setup.

Out of the box, WordPress offers easy user management through its dashboard and if you’re running some type of blog or editorial site, there’s no need to deviate. But if you’re building an application, there are alternative ways to handle users.

Case in point: say that designer has created a solid look and feel for the site. If you force users to use the built-in dashboard to create or manage their profiles, then you’re yanking them out of the site, dropping them into some new experience, and then returning them to the site from which they came.

Lame, right?

There are better ways to introduce user registration and profile management into an app built on WordPress. Though your mileage may vary based on the needs of you project, here’s a how you can programmatically create a user in WordPress.

Continue reading

WordPress Generators and Why I Dislike Them

WordPress Generators

At this point, it’s relatively easy to find a generator to do almost anything you want with WordPress. In fact, you can assemble an entire theme with custom post types, taxonomies, and options all without actually writing any code.

Bummer.

But you know what I’m talking about – generators are small web-based tools that are used to, er, generate code for you based on a couple of inputs that you specify on an interface.

Off the top of my head, I can think of…

  • Generators for custom post types
  • Options frameworks for easily creating settings pages
  • Generators for taxonomies
  • Custom theme generators
  • …and more.

Don’t get me wrong, I think that these tools have their place in the development space (in fact, my boilerplates have even been converted to generators!).

But as a profesional developer and someone who cares about writing quality code tailored exactly for the problem at hand and as someone who wants to create the highest-quality products that I can, I dislike WordPress generators.

Continue reading

« Older posts Newer posts »

© 2025 Tom McFarlin

Theme by Anders NorenUp ↑