Software Engineering in WordPress, PHP, and Backend Development

Tag: WordPress (Page 172 of 219)

Articles, tips, and resources for WordPress-based development.

Programmatically Upload Files in WordPress (and Create Associated Meta Data)

This is post one of two on how to upload files in WordPress and created associated meta data.

In a recent project, I’ve been working on a plugin in which the user needs to upload a file to a custom post type by using an input element (of type file, obviously) rather than using the WordPress media uploader.

In addition to being able to upload the file, the user must also be able to view the file and remove the file (via Ajax) by an available anchor.

In order to do this, the plugin has to do the following:

  1. Upload the file to the `uploads` directory
  2. Save the file URL to the custom post type’s post meta data
  3. Save the file path to the custom post type’s post meta data
  4. Delete the file from the `uploads directory
  5. Clear the post meta data referencing the file

The primary reason that you have to store the file’s location on disk is because you can’t rely on PHP to delete a file via remote requests.

To that end, you need to be able to store not only where the file is on disk (for the sake of being able to delete), but also the URL of the file so that visitors or viewers can access the file via their browser.

Over the next two articles, I’ll share how to programmatically upload files in WordPress and save their associated meta data, and then I’ll share how to programmatically delete the files in WordPress as well as their associated meta data.
Continue reading

Filtering wp_title and Why This Matters

For anyone who has experience in building WordPress themes – or even just one theme – or anyone who has experience in working with child themes, or simply modifying a core theme, then you’re more than likely with <a title="wp_title" href="http://codex.wordpress.org/Function_Reference/wp_title" target="_blank">wp_title</a>.

It’s one of the tags in WordPress that’s easy to usd and that’s easy to understand. Straight from the Codex:

Displays or returns the title of the page. A separator string can be defined, and …, that separator can be designated to print before or after the title of the page.

This tag can be used anywhere within a template as long as it’s outside The Loop on the main page, though is typically used in the <title> element for the head of a page.

Not much to it, right?

But it’s also one of the tags that can be abused which can cause problems especially as it relates to plugins.

Continue reading

Developers Need Help Marketing WordPress Themes

If you hang around the WordPress Community long enough (that is, those people who are involved in working on WordPress or building something on WordPress in some way), you’ll notice that we all have a tendency to aim to build the best thing possible – whatever that may be.

At least, that’s what we claim to be doing.

And I’m just as guilty of this as the next person.

But let’s face it: developers need help marketing WordPress themes. Perhaps designers do, too. And let’s not forget plugins or other add-ons.

Basically, I think that we get so involved with the community of which we’re a part, we forget about the market and the terms in which they think. We’re busy trying to help one another other, perhaps even impress one another, and even working to try to out-do each other (I mean, come on, that is competition, right?), that we end up marketing our products in the same way every single time.

And you know what I’m talking about.

Continue reading

Adding Post Pagination Attributes in WordPress

Be sure to checkout this comment to see why adding title attributes may not be a good idea.

When it comes to working with pagination in WordPress, it’s relatively easy to manage:

  • There is pagination for index and archive pages.
  • There is pagination at the single post level.

Each of which usually consists of doing the following:

Enough enough, right?

But there are times in which you may want to add or enhance some of the attributes that are on each of these anchors.

Continue reading

Officially Partnering with Envato and WordPress

For the past several years, I’ve contributed a number of articles and premium tutorials to Envato specifically around WordPress.

The content has ranged from topics such as Strategies For Supporting WordPress Plugins up through my current series on Using WordPress For Web Application Development.

To say that I enjoy contributing code and content to WordPress is an understatement.

To that end, I’m proud to announce that I – or, more specifically, Pressware – is officially partnering with Envato and WPTuts+ in 2014.

Continue reading

« Older posts Newer posts »

© 2025 Tom McFarlin

Theme by Anders NorenUp ↑