A couple weeks ago I had a chance to present on PHP for WordPress at WordCamp Baltimore 2015. Thanks to the good folks who recorded and got everything together to post on WordCamp.tv you can now watch the video of the talk.
I’m very excited to be back at a WordCamp in Baltimore, a town I love. Today I am speaking on PHP for WordPress, a topic near and dear to my heart since I learned PHP via WordPress and, as a teacher, guide others on this path as well.
After you check out the slide notes, please check out the Trailer for my PHP for WordPress Course from Treehouse.
The other week I had the great privilege of speaking at WordCamp Raleigh 2013. Here are my slides from the talk
I came across BackPress while reading about the WordPress Plugin API a while back. Basically it provides all of the core actions and filters from WordPress core to be used outside of the WordPress environment.
Not sure when I’ll have the chance to work with the framework, but it looks really cool and an awesome solution for the right problem.
Thanks to Jonathan Perez for this little function to use remove_action conditionally. Helped when I was working on a WooCommerce project.
EDIT: This file has been moved to woocommerce/includes/wc-template-hooks.php
Fully customizing WooCommerce did not make sense to me until I finally tracked down this file: /wp-content/plugins/woocommerce/woocommerce-hooks.php.
This file lists all of the hooks and all of the actions that are added to the hooks. So, if you’ve ever tried searching through the rather abstracted template files and not be able to find what you’re looking for to customize, check out the woocommerce-hooks.php file.
I didn’t find any direct mention of this file in the docs, so hopefully the 2.0 WooCommerce docs will have this file at least mentioned as the place to go to see the default loading of actions.
Have to say though, that once found, everything was super clear to figure out, so big thanks to the dev team for clean coding!
There are some times when you want to test for the post type of an item in your loop. You may use this in your functions.php file for taking dynamic actions for custom post types, or you may need to use it directly in your template.
Either way, here is how you would save the post type as a variable:
get_post_type( $post->ID );
You can also use the function conditionally like this:
if( get_post_type( $post->ID ) == 'custom_post_type_name'): // Do custom code here endif;
This function can be particularly helpful if you’re needing to work a lot with custom post types.