remove_action() hook not working

Actions (and filters) can be removed only after they had been set, therefor you will have to figure out when in the execution path the woocommerce_template_single_excerpt is being added, and remove it only after that.

add extra parameter in default hook in wordpress

You don’t really need to add this parameter, you can use global $post; function bp_add_visibility_to_activity( $content, $user_id, $activity_id ) { global $post; $post_id = $post->ID; // do stuff } add_action( ‘bp_activity_posted_update’, ‘bp_add_visibility_to_activity’, 10, 3 ); Note that $post->ID will return null if your are not in a post or page, so you maybe need to … Read more

Which action hook to update custom field at network/site-info.php in multisite on update site info

After some more research I found a solution, turned out that I had to use admin_init.. function pg_save_custom_site_options(){ global $pagenow; if( ‘site-info.php’ == $pagenow && isset($_REQUEST[‘action’]) && ‘update-site’ == $_REQUEST[‘action’] ) { if ( isset( $_POST[‘blog’][‘custom_limit_amount’] ) ) { $new_field_value = intval( $_POST[‘blog’][‘custom_limit_amount’] ); if( is_int($new_field_value) ){ update_blog_option( $_POST[‘id’], ‘custom_limit_amount’, $new_field_value ); } } } … Read more

Clone the “proceed to cart” button and place it above checkout on the cart page, but only appear display size is 320px

Just call woocommerce proceed-to-checkout-button template in woocommerce_before_cart action hook as follows- add_action(‘woocommerce_before_cart’, ‘add_wc_button_proceed_to_checkout’); function add_wc_button_proceed_to_checkout(){ echo ‘<div class=”wc-proceed-to-checkout”>’; wc_get_template( ‘cart/proceed-to-checkout-button.php’ ); echo ‘</div>’; }

how to retrieve post_id under woocommerce_add_to_cart_validation hook?

woocommerce_add_to_cart_validation passes the product id as the second argument to the callback function, so you can access it like this: function custom_fields_validation( $passed_validation, $product_id ) { if( isRecurring( $product_id ) ) { if ( empty( $_POST[‘inputday’]) ){ wc_add_notice( __( ‘Please select field 1;’, ‘woocommerce’ ), ‘error’ ); return false; } if ( empty( $_POST[‘inputtime’] )){ … Read more

How to filter wp_get_recent_posts() to only posts that have thumbnails?

You can pass arguments to pass meta_query to your wp_get_recent_posts() function. wp_get_recent_posts() makes call for get_posts(), so you can make use of all the arguments get_posts() or WP_Query uses. As per your need. $args= array( ‘meta_query’ => array(array(‘key’ => ‘_thumbnail_id’)) ); $recent_posts = wp_get_recent_posts($args); Along with other arguments you want to pass to your function. … Read more

WooCommerce Admin Only Email Hook

The hook woocommerce_email_order_details has 4 parameters which can help you to identify the correct message. add_action( ‘woocommerce_email_order_details’, ‘so274215_add_transaction_id’, 10, 4); function so274215_add_transaction_id( $order, $sent_to_admin, $plain_text, $email ){ // decide here wether to show your transaction id if ( ! $sent_to_admin ) echo ‘<span style=”color:#555;font-size:1.5em;”>Transaction ID: ‘.get_post_meta( $order->id, “_transaction_id”, true ).'</span>’; } As far as I … Read more

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