wp_mail attachment not working

Attachments should always use the absolute filesystem path. Also to change the Content-Type of the email you should use the wp_mail_content_type filter. <?php function my_custom_email() { $to = ‘[email protected]’; $subject=”WordPress wp_mail”; $message=” <html> <body> <table rules=”all” style=”border-color: #666;” cellpadding=”10″> <tr>Hello WordPress</tr> </table> </body> </html> “; $attachments = array( WP_PLUGIN_DIR . ‘/my-plugin/uploads/sample_photo_01.jpg’ ); $headers[] = ‘From: … Read more

Create a plugin with Calendar picker

jQuery Datepicker is included in WP Core, you can add it to your functions.php (for themes) or index.php (for plugins) function styles_scripts() { wp_enqueue_script(‘jquery-ui-datepicker’); // Enqueue some theme-roller or default style… wp_enqueue_style(‘jquery-style’,’http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.2/themes/smoothness/jquery-ui.css’); } add_action( ‘wp_enqueue_scripts’, ‘styles_scripts’, 11 ); Than in the HTML part where you need the datepicker <input type=”text” id=”MyDate” name=”MyDate” value=””/> And finally … Read more

get_option compatible with wordpress network (multisite)?

When working with multisites, there are two commonly used sets of functions for pulling/updated options. Now… how you structure your options and save them to the database is up to you. It depends on the functionality your plugin is adding, and where you want to store/pull options. Single Site Configuration get_option() and update_option() are used … Read more

Can I use a method from an existing plugin as an action hook?

It sounds like you are looking for do_action() In your method that you wrote add do_action and it will trigger your new custom action. Then you can use add_action() in the same way you use the build in actions. https://developer.wordpress.org/reference/functions/do_action/ Example of your method in the class… public function some_method() { $foo = ‘puppy’; $bar=”bunny”; … Read more

WordPress redirect all 404 pages to the Homepage

Note: I have read somewhere that redirecting all 404 to Homepage is not a good approach for SEO purposes Simplest way to redirect all 404 to homepage in wordpress. if( !function_exists(‘redirect_404_to_homepage’) ){ add_action( ‘template_redirect’, ‘redirect_404_to_homepage’ ); function redirect_404_to_homepage(){ if(is_404()): wp_safe_redirect( home_url(“https://wordpress.stackexchange.com/”) ); exit; endif; } }