How to send email with wp_mail() with from email taken from contact form instead of the host?

You don’t need to pass the from name and email to PHPMailer in your code as it will take it from $headers so try the following: add_action( “phpmailer_init”, “send_smtp_email” ); function send_smtp_email( $phpmailer ) { // ini_set(“sendmail_from”,”[email protected]”); // ini_set(“sendmail_path”,”[email protected]”); // Define that we are sending with SMTP $phpmailer->isSMTP(); // The hostname of the mail server … Read more

How to keep a CPT stick to specific position?

If you index $related_posts by position along with $ad_posts, you can probably splice/insert them in at the same position… eg. function wpse_210493_apply_advertising_position(&$posts, $return = false) { $ad_posts = array(); $content_posts = array(); $related_post = array(); // Seperate $posts into “Ads” and “Content” arrays based on whether or not they have ‘rw_adversiting_position’ meta-data foreach ($posts as … Read more

How to display all custom fields associated with a post type – IN THE ADMIN AREA?

You need an action called manage_$post_type_posts_custom_column. This will allow you to add columns to your custom posts page. To be more precise, you need a filter to generate the column and an action to fill it with content. In your case something like this (untested): add_filter( ‘manage_chimpmunks_posts_columns’, ‘set_custom_size_column’ ); add_action( ‘manage_chimpmunks_posts_custom_column’ , ‘fill_custom_size_column’, 10, 2 … Read more

Shortcode to eliminate and replace with

You’ve got the $content available to you in your remove_p function – so inside that function just look for the existence of a special string (i.e. your “shortcode”), to allow the filter to do the str_replace. For example: if ( false !== strpos( $content, “[p-filter]”) ) { $paragraphs = array(“<p>”,”</p>”,”[p-filter]”); $noparagraphs = array(“”,”<br>”,””); return str_replace( … Read more

single- and archive- templates not being applied to custom post types, not even after flushing permalinks

Answering my own question here, for anyone who might encounter this problem in the future. The cause for the right templates not loading was having uppercase letters in my template filename. Changing all characters in the filename to lowercase resolved the problem, and the templates are now being applied as they should. I’m still unsure … Read more