X

Append shortcode after content in_category

This snippet will append any shortcode after the_content within a specific category. You will need to change the category that I currently have set as snippets. You will also need to change the shortcode [wpsnipp_shortcode] to something useful. Once done just add this snippet to the functions.php of your WordPress theme.

    function wpsnipp_append_shortcode_to_content( $content ) {
          if( is_single() ) {
            if (in_category('snippets')) {
              $content .= do_shortcode( '[wpsnipp_shortcode]' );
            }
          }
          return $content;
      }
      add_filter('the_content', 'wpsnipp_append_shortcode_to_content');

Comments   Leave a Reply

Add a Comment

We're glad you have chosen to leave a comment. Please keep in mind that all comments are moderated according to our privacy policy, and all links are nofollow. Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.

WordPress Launch Checklist

The Ultimate WordPress Launch Checklist

We've compiled all the essential checklist items for your next WordPress website launch into one handy ebook.
Yes, Send Me the Free eBook!