Hook that get’s triggered when the author of a post is changed

There is no special hook to author change. But you can achieve it by using post_updated hook. Example: add_action(‘post_updated’, ‘prefix_on_update_author’, 10, 3); function prefix_on_update_author($post_ID, $post_after, $post_before) { if ($post_after->post_author != $post_before->post_author) { // author has been changed // you can add your own hook here or write your code } } Here is the codex … Read more

Is there a hook which fires after all thumbnails are generated?

Thumbnails in WordPress can be generated by using wp_generate_attachment_metadata(), this function fires a filter after generating all the thumbnails wp_generate_attachment_metadata and the filter provides $metadata and $attachment_id to the hooked functions. You can hook your custom function to this filter. $metadata : Attachment metadata. What you need is $metadata[‘sizes’][‘<size-name>’], the <size-name> is the name of … Read more

Hook that fires when admin setting is saved

There is the filter ‘pre_update_option_’ . $option. You have to know the option name. Options can be updated from front-end too, so WordPress doesn’t make a difference here. Then there is an action: ‘update_option’, you get the arguments $option, $oldvalue and $_newvalue. Finally, if the update went successful, you get two further actions: do_action( “update_option_{$option}”, … Read more

How to remove the Theme Customization Button from the dashboard and themes options page?

With the lastest version of WordPress (4.3) you can now natively remove the customizer’s theme switch setting without resorting to CSS hacks. /** * Remove customizer options. * * @since 1.0.0 * @param object $wp_customize */ function ja_remove_customizer_options( $wp_customize ) { //$wp_customize->remove_section( ‘static_front_page’ ); //$wp_customize->remove_section( ‘title_tagline’ ); //$wp_customize->remove_section( ‘nav’ ); $wp_customize->remove_section( ‘themes’ ); } add_action( … Read more

What does (10, 2) mean when used with add_filter

Have a look at the codex page for add_filter. The 10 is the $priority parameter (10 is default) which defines when your function will run in regards to the other functions which are attached to the nav_menu_css_class filter. 2 is the $accepted_args parameter which tells wordpress how many parameters the function you want to add … Read more

Hook when category is added to post

You may want to try: do_action(‘set_object_terms’, $object_id, $terms, $tt_ids, $taxonomy, $append, $old_tt_ids); You can find it under this Docs and the action is located at wp-includes/taxonomy.php add_action(‘set_object_terms’,’wpse5123_set_object_terms’,10,4); function wpse5123_set_object_terms($object_id, $terms, $tt_ids, $taxonomy){ if($taxonomy == ‘category’){ echo ‘<pre>’; print_r($terms); echo ‘</pre>’; exit; } } The code above isn’t tested but I think you get the point.

Where to hook into post content?

You can use the_content with an high prioriety (lower number). add_filter( ‘the_content’, function( $content ) { return ‘Hello World ‘.$content; }, 0); You can even use negative priority: add_filter( ‘the_content’, function( $content ) { return ‘Hello World ‘.$content; }, -10); Note that this will apply everytime ‘the_content’ is used, no matter the post type, or … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)