Add Class to Specific Paragraph of the_content()

The following bit of code adds a class to the first paragraph output by the_content: function first_paragraph($content){ return preg_replace(‘/<p([^>]+)?>/’, ‘<p$1 class=”intro”>’, $content, 1); } add_filter(‘the_content’, ‘first_paragraph’); Add the above to your theme’s functions.php file. Then in your CSS add something like: p.intro { font-weight:bold; } I can’t claim credit for this solution (see this thread … Read more

wp_mail – Remove sitename from email subject

Finally, I wrote some code and it worked very well. I hope it helps. Put this in your functions.php file //remove sitename from email subject add_filter(‘wp_mail’, ’email_subject_remove_sitename’); function email_subject_remove_sitename($email) { $blogname = wp_specialchars_decode(get_option(‘blogname’), ENT_QUOTES); $email[‘subject’] = str_replace(“[“.$blogname.”] – “, “”, $email[‘subject’]); $email[‘subject’] = str_replace(“[“.$blogname.”]”, “”, $email[‘subject’]); return $email; }

How can I detect if a user changes their password?

WordPress sends an email to the admin’s email when a user resets their password. To get a notification when a user changes their password you could hook into the profile_update action which is fired when a user’s profile is updated. When the action is fired WordPress has already validated and updated the user’s details we … Read more

Get excerpt from $post->post_content

When in the loop, this will produce excerpt from $post->post_content directly: <?php echo wp_trim_excerpt(); ?> Read more HERE. Alternative Solution: If you are not in the loop, then, you may use similar implementation as done in the wp_trim_excerpt function: $text = strip_shortcodes( $post->post_content ); $text = apply_filters( ‘the_content’, $text ); $text = str_replace(‘]]>’, ‘]]&gt;’, $text); … Read more

add_filter to youtube embeds?

Yes, there is a filter for Oembeds. Two (or even more) in fact: oembed_result will be called before it is put in the cache (so only once per external embed), and embed_oembed_html after the cache (so every time the item is displayed). If you only need to modify it once, oembed_result is probably your friend. … Read more