Software Engineering in WordPress, PHP, and Backend Development

Author: Tom (Page 374 of 424)

Extending WordPress Plugins with Hooks

I've closed comments on this post as I'd like to keep the discussion on the source post.

Earlier this week, I shared my thoughts on custom, non-standard hooks within the context of WordPress themes which resulted in a great discussion in the comments and on Twitter, so it seems only appropriate to share a resource on how to get started with WordPress plugin hooks.

WordPress Plugin Hooks

Last week, Pippin Williamson of Pippin’s Plugins published a terrific article on Envato that explains how to write extensible plugins with WordPress plugin hooks.

Continue reading

How To Get a Page’s Permalink By Slug

If you’re used to working with The Loop, then you’re all too familiar with the_permalink. Simply put, it’s how to get the link to the post currently being rendered in the browser.

But if you’re working on anything more advanced than using the typical Loop, then you may be looking to get the permalink for a post by other means – perhaps by a page slug or by a page’s title.

I’ve had to do this in some recent work, as well, so here’s what I do when I need to get permalink by slug:

Continue reading

Why I’m Against Placing Custom Hooks in WordPress Themes

One of the things that I my team and I are often asked is if we’re ever going to place hooks in our core theme files for Standard. The short answer is “no,” but there’s actually a few reasons why I’m personally against placing custom hooks in WordPress themes.

Although this is stemming largely from building and managing a commercial theme, the discussion isn’t limited to that particular scenario. Rather, this is something that I’ve actually discussed with a number of other WordPress users and developers.

Overall, I’m generally against placing custom hooks in WordPress theme files, so I thought I’d share my reasons why I’m not a fan of doing this.

Continue reading

How I Organize My Files When Developing WordPress Themes

I recently shared how I organize my files when developing WordPress plugins, but since I also work with themes and have recently been building two applications using WordPress, I thought I’d also share my thoughts on organizing WordPress theme files.

For what it’s worth, I think that some developers – especially beginners – often try to make the plugin model fit the theme model or vice versa, and although both types of projects are aimed specifically at WordPress, they require different approaches.

Simply put, theme file organization differs from plugin file organization. With that said, here’s how I organize my files when developing WordPress themes.

Continue reading

Resolving wp_redirect and the “Headers Already Sent” message

I’ve been working on building a web application in WordPress on which I’m implementing a set of rewrite rules to introduce RESTful routing into the application.

Once the application is done, I hope to provide a significantly more in-depth post on how I built it, but in the mean time I figured I’d cover how I’m handling certain challenges that I’ve faced in development.

In this case, I needed to fire a call to wp_redirect after a certain event happened, but kept getting the PHP error:

Cannot modify header information - headers already sent by (output started ... )

Here’s how I ended up resolving the wp_redirect headers already sent message.

Continue reading

« Older posts Newer posts »

© 2024 Tom McFarlin

Theme by Anders NorenUp ↑