Whenever my wife and I take an extended vacation I always bring along our Apple TV.
At the end of a long day filled with adventure and fun it’s nice to just snuggle up together and watch your favorite show on Netflix or rent a new release comedy.
I’ve found that hotel television is still so primitive and annoying. The on-demand movie rentals are limited and very pricey, the regular programming is usually in standard definition, and you’re forced to channel surf without a guide. Ain’t nobody got time for that!
When I book a hotel I always make sure there is free Wi-Fi and that they say there are “flat screens” in every room, this tells me that there must be an HDMI input on it somewhere.
It seems we’re left with no choice but to do some friendly hacking to circumvent this annoying speed bump! 🙂
I had neglected to prefix the post type names in some of my themes, and as it turns out, so did another popular WordPress plugin. Long story short: this plugin became unusable when running my themes, and this did not make my users very happy.
It became clear that I needed to bust out some ninja moves to overcome this dilema.
The code below is the solution I drafted – maybe it will help you too. It’s a function that runs when the theme is in use, and rewrites the post type names in the database with any prefix you choose.
After the theme is activated the specified post types will be renamed to: fjarrett_acme, fjarrett_foo and fjarrett_bar.
Sadly, there is not yet a hook that will fire only when themes are activated/updated. The after_setup_theme action is a little misleading in that it fires when WordPress sets up the current theme, not when an admin activates and/or updates the current theme.
So, it’s basically firing with every load of WordPress when the theme is active. Someone first made a patch for this 3 years ago and it looks like it’s finally being revisited.
For that reason, this is by no means the most resource-friendly solution, but we are killing the script if the prefixed post type already exists – which requires an additional query – but this is crucial for two reasons:
So we’re not attempting to update the database with every page load – after the original post types are given prefixes the database update will never run again.
So other plugins/themes (like the one I was in conflict with) can be installed later, creating their blasphemous post type names, and we won’t attempt to rewrite them.
Hopefully this is helpful to you and your project in some way. If so, please tell me about it the comments!
If you want to use WordPress functionality in a PHP file that exists outside of your WordPress installation then you need to include wp-load.php. Perhaps you could call this “hooking into WordPress”.
Maybe you’re already using some sort of relative path method, like:
But this can create problems if directories change. You need a clean, dynamic way to get wp-load.php. So here is the simplest way to do it, with just two lines of code (place it at the very top of your file):