Articles of hooks

Modify featured image URL at runtime

Simple question: I know this can be achieved with a hook somewhere, but I’m having trouble tracking down exactly where I need to look to implement it. Basically, I need to hook into the featured image / thumbnail hook and update the image URL on the fly. Can someone lend a hand on how I […]

Use remove_meta_box conditionally on custom post type

I have a custom post type of people with some custom taxonomy boxes, i want to hide these when on child pages. I have found remove_meta_box works fine but i just can’t access the $post object within the action. Currently i have function remove_post_custom_fields($post) { global $post; if( count($post->ancestors) > 0 ){ remove_meta_box( ‘staff-typediv’ , […]

What hooks do I need to hook into to capture ever wp_user creation/change?

I have a wordpress site and I have an external database I need to keep updated with the user information. Whenever a user is created, updated, or otherwise modified by something like an admin, I need to update the other database. I thought there would be one or two hooks I would need to hook […]

Adding bootstrap classes to video shortcodes

I want to make videos responsive… There is a function in /wp-includes/media.php file: line 2497: $html_atts = array( ‘class’ => apply_filters( ‘wp_video_shortcode_class’, ‘wp-video-shortcode’ ), ‘id’ => sprintf( ‘video-%d-%d’, $post_id, $instance ), ‘width’ => absint( $atts[‘width’] ), ‘height’ => absint( $atts[‘height’] ), ‘poster’ => esc_url( $atts[‘poster’] ), ‘loop’ => wp_validate_boolean( $atts[‘loop’] ), ‘autoplay’ => wp_validate_boolean( $atts[‘autoplay’] […]

A similar hook as wp_head for the admin area

I’m adding a node to the toolbar and wish to tweak the css a bit. I don’t have any external CSS files and I’m echoing the CSS using the wp_head action hook. Is there a similar action hook that I can use to echo the CSS everywhere? Both front-end and admin area?

Deactivate JS Script in Plugin Shortcode

I am using a plugin which enqueues a javascript file in one of its shortcode functions (which I run on a page). I don’t want this file to be loaded. So I tried using wp_dequeue_script in my functions.php file but this didn’t work. Perhaps my functions.php file is loaded before the shortcode that’s in the […]

Add Adsense code between job listings – wp job manager plugin

I am using the wp-job-manager plugin and i want to add an Adsense code between the job listings ( after fifth job listing ) in the page with [jobs] shortcode. The function that outputs the jobs resides in class-wp-job-manager-shortcodes.php function output_jobs( $atts ) Because i don’t know how to start to add that Adsense code […]

How to access page variable inside action hook

I have an action hook which simply displays a contact form for signup: add_action(‘woocommerce_single_product_summary’,’add_product_signup’, 10, 2); function add_product_signup() { do_shortcode(‘[contact-form-7 id=”20709″ title=”Product Sale Notification Signup”]’); } This works ok BUT… I want to only show the form if the product is NOT on sale. How can I access the ‘on_sale’ variable to test for true/false […]

How to register custom post types in a plugin?

I’m using toscho’s Plugin Class Demo code as a foundation for a plugin I’m developing. Amongst other things, my plugin registers a custom post type. public function plugin_setup() { $this->plugin_url = plugins_url( ‘/’, __FILE__ ); $this->plugin_path = plugin_dir_path( __FILE__ ); $this->load_language( ‘myplugindomain’ ); // more stuff: register actions and filters add_action( ‘init’, array( ‘MyPluginClass’, ‘register_my_post_types’ […]

How to delete an user including data from custom database tables

Is it possible to remove an user from within the back-end including all data related to this user even from custom tables? I used the add_action( ‘delete_user’, ‘my_delete_user’ ); hook and also execute a delete query to delete data from a custom table (related to that user) but only data from the user and user_meta […]