Support » Plugin: Random Content » Strip html tags

  • Hi Jeremy, thanks for your hard work on this plugin. I want to suggest one addition: the ability to add a shortcode attribute to strip the HTML. WordPress is otherwise adding paragraph tags and if you’re using the random content inside a paragraph, it doesn’t work well. I added this code to the plugin to make it work for me, but I believe it would be a good feature for others.

    First, grab the new attribute

    $a = shortcode_atts( array( 'group_id' => '', 'num_posts' => 1, 'strip_html' => '', ), $atts );

    Then, later, I changed this section:

    ` while ( $my_query->have_posts() ) : $my_query->the_post(); if ( $a[‘strip_html’] == ‘1’ ) { $content .= wp_strip_all_tags(apply_filters(‘the_content’, get_the_content() ), 1); } else {
    $content .= apply_filters('the_content', get_the_content() ); } endwhile;

    I’m not a developer, so there might be a better way to do it.

    Thanks again for the plugin, great job!

    • This topic was modified 4 years, 8 months ago by learnthat. Reason: Fixed code tags
    • This topic was modified 4 years, 8 months ago by learnthat.
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Strip html tags’ is closed to new replies.