Are there any hooks that alter the 404 logic?

After a bit more slogging through code and Googling, I found the answer. It’s contained in this thread (see Otto42’s post), but for the record, adding the following to your plugin will override the 404 handling for the conditions you specify: add_filter(‘template_redirect’, ‘my_404_override’ ); function my_404_override() { global $wp_query; if (<some condition is met>) { … Read more

WordPress hooks/filters insert before content or after title

Just use the the_content filter, e.g.: <?php function theme_slug_filter_the_content( $content ) { $custom_content=”YOUR CONTENT GOES HERE”; $custom_content .= $content; return $custom_content; } add_filter( ‘the_content’, ‘theme_slug_filter_the_content’ ); ?> Basically, you append the post content after your custom content, then return the result. Edit As Franky @bueltge points out in his comment, the process is the same … Read more

Get a list of all registered actions

Filters and actions are both assigned to hooks. Functions assigned to hooks are stored in global $wp_filter variable. So all you have to do is to print_r it. print_r($GLOBALS[‘wp_filter’]); PS. add_action function makes a add_filter call. And the latter does $wp_filter[$tag][$priority][$idx]. NOTE: you can directly add this code in functions.php, and you will see a … Read more

How to know what functions are hooked to an action/filter?

Look into the global variable $wp_filter. See my plugin for a list of all comment filters for an example: <?php /* Plugin Name: List Comment Filters Description: List all comment filters on wp_footer Version: 1.1 Author: Fuxia Scholz License: GPL v2 */ add_action( ‘wp_footer’, ‘list_comment_filters’ ); function list_comment_filters() { global $wp_filter; $comment_filters = array (); … Read more

Where is the right place to register/enqueue scripts & styles

Why registering and queuing properly matters it should be in time – earlier than script/style is up for being output to page, otherwise it is too late; it should be conditional – otherwise you are loading stuff where you don’t need it and cause performance and functionality issues, for this you need WP environment loaded … Read more

Is there a save_post hook for custom post types?

the hook is the same save_post just make sure its your post type ex: add_action(‘save_post’,’save_post_callback’); function save_post_callback($post_id){ global $post; if ($post->post_type != ‘MY_CUSTOM_POST_TYPE_NAME’){ return; } //if you get here then it’s your post type so do your thing…. }