[resolved] Span classes being stripped. (2 posts)

  1. mpmchugh
    Posted 3 years ago #

    I added the following to allow for br and span tags with classes, but the classes keep getting stripped.

    add_filter( 'subheading_tags', function( $tags ) {
     	$tags['span'] = array('class');
     	$tags['br'] = array();
        return $tags;
    } );

    Did I do it wrong?

    Also, should class names be in quotes? I tried with single, with double and none. All got stripped.

    Just trying to do something like this:

    <span class="home1st">Lorem ipsum dolor sit amet,</span><span class="home2nd">consectetuer adipiscing elit.</span>

    But I get this after saving:

    <span>Lorem ipsum dolor sit amet,</span><span>consectetuer adipiscing elit.</span>


  2. Steve
    Plugin Author

    Posted 3 years ago #


    Referring back to the WordPress documentation, it looks as though I may have including some slightly incorrect / misleading information in the Frequently Asked Questions relating to this topic.

    It should be possible to adjust your snippet to use 'class' as an array key rather than value, therefore something along the lines of this should help:

    add_filter( 'subheading_tags', function( $tags ) {
     	$tags['span'] = array('class' => array());
     	$tags['br'] = array();
        return $tags;
    } );

    I have also adjusted the readme file for the next release to reflect this - hope it helps.

    - Steve

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • SubHeading
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic


No tags yet.