add_action hook for publish_post not working

When a post is published/saved, it does not do it in a single script execution. It redirects to a different script, does the save, then redirects back to where you started. If you want to confirm that your hook is working, use update_option(), and delete the option immediately after displaying it so it’s not latent … Read more

How to use a WooCommerce action hook?

If you don’t intend your meta field to be specific to a particular product type you can do the following ( which is what I do in my own WooCommerce extension ). function new_post_meta () { if (isset($_POST[‘location’])) update_post_meta( $post_id, ‘location’, json_encode($_POST[‘location’]) ); } add_action( ‘woocommerce_process_product_meta’, ‘new_post_meta’ ); or to limit this to a particular … Read more

‘save_post’ hook not working in WP 3.5

attachment_fields_to_save is still called. Just tried out this on my wordpress 3.5. installation and the following code killed wordpress when saving an image. add_filter(‘attachment_fields_to_save’, function() { die(‘attachment_fields_to_save’); });

“admin_enqueue_scripts” hook or $_GET[‘page’]?

The advantage of using the value provided by WordPress in the hook variable is future compatibility with WordPress Versions and not having to worry about $_GET variable manipulation by way of the user or another WordPress plugin. Checking the $_GET array works, but can be unreliable especially when other poorly coded plugins start messing with … Read more

Alternative to new_to_publish Hook for Custom Statuses

new_to_holding doesn’t exist as a post status transition – you need to use the generic transition_post_status action. Something like (untested): add_action(‘transition_post_status’,’my_holding_function’, 10, 3); function my_holding_function( $new_status, $old_status, $post ) { if ( ‘holding’ == $new_status ) { // do stuff } }

WordPress’s “Text” Format

Text its just plain text, just as its saved in your db. WordPress changes line breaks with paragraphs with the function wpautop, through the filter the_content and the_excerpt. If you need to remove the wpautop behavior, you can remove the filter by doing this in your theme’s functions.php: remove_filter( ‘the_content’, ‘wpautop’ ); remove_filter( ‘the_excerpt’, ‘wpautop’ … Read more

Use a variable created in get_header to calculate stuff in wp_footer

You need to redeclare the variable in your end_time() and also you don’t need the user to be logged in.. You can try the below answer. // LOAD TIME CHECKER function start_timer() { global $time_start; $time_start = microtime(true); } add_action(‘wp_head’, ‘start_timer’, 1); function end_time() { //try redeclaring the var global $time_start; echo ‘ <div class=”clearfix”></div> … Read more

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