How can I send to multiple Contact Form 7 recipients based on form input? [closed]

No need to write any code, Contact form 7 has features of Additional Headers in the Mail section. In that you just need to write the email’s header inside the Additional headers textbox in Mail(Second Tab) section. Put this inside the Additional Headers textbox. Cc: [friend1-email], [friend2-email], [friend3-email], [friend4-email], [friend5-email] OR You can alter the … Read more

How to check if which hook triggered the call to a function?

I found the magic code you need. Use current_filter(). This function will return name of the current filter or action. add_action(‘my_test_hook_1′,’my_test_callback_function’); add_action(‘my_test_hook_2′,’my_test_callback_function’); add_action(‘my_test_hook_3′,’my_test_callback_function’); add_action(‘my_test_hook_4′,’my_test_callback_function’); function my_test_callback_function(){ $called_action_hook = current_filter(); // ***The magic code that will return the last called action echo “This function is called by action: ” . $called_action_hook ; } For reference: https://developer.wordpress.org/reference/functions/current_filter/

Add action hook conditionally – only when home.php in use

Use is_home instead, as is_page_template will not work for home.php as its technically not a page template in the traditional sense. add_action(‘template_redirect’, ‘are_we_home_yet’, 10); function are_we_home_yet(){ if ( is_home() ) { //your logic here } } Revised: add_action(‘template_redirect’, ‘are_we_home_yet’, 10); function are_we_home_yet(){ global $template; $template_file = basename((__FILE__).$template); if ( is_home() && $template_file=”home.php” ) { //do … Read more

‘post_type_link’ filter not working

It is not a bug. As @LuisSanz pointed out, post_type_link isn’t used for the built-in post post type. It is used for custom post types only. Skim through get_permalink() function, you will find out that WordPress doesn’t use post_type_link filter but uses post_link filter. It means that you’re using wrong filter. Then, change post_type_link to … Read more

Are hooks called synchronously?

The do_action() and apply_filters() are both wrappers of the WP_Hook::apply_filters() method, that invokes the registered callbacks in sequential order (src). Here’s a simple test: Let’s define a callback wrapper: $callback_gen = function( $seconds ) { return function() use ( $seconds ) { sleep( $seconds ); printf( ‘%s finished’ . PHP_EOL, $seconds ); }; }; Next … Read more

Remove Woocommerce product link

The way I’ve done this was to take a copy of content-product.php and paste it into the root of your theme folder. Comment out do_action( ‘woocommerce_before_shop_loop_item_title’ ); and do_action( ‘woocommerce_after_shop_loop_item’ ); Quick and dirty, but it worked for me.

How to add a button to custom post type’s posts-page

You can add button via add_meta_box function. function add_your_meta_box(){ add_meta_box(‘your-metabox-id’, ‘Title’, ‘function_of_metabox’, ‘custom_post_type’, ‘side’, ‘high’);} add_action(‘add_meta_boxes’, ‘add_your_meta_box’); function function_of_metabox() {?> <input type=”submit” class=”button button-primary button-large” value=”Add New” id=”add-new”/> <?php } if you add to multiple post type, you should use foreach loop. function add_your_meta_box(){ $types = array(“post”,”page”,”custom_post_type”); foreach($types as $type){ add_meta_box(‘your-metabox-id’, ‘Title’, ‘function_of_metabox’, $type, ‘side’, … Read more

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