WordPress.org

Ready to get started?Download WordPress

Forums

Remove shortcodes from auto excerpt (3 posts)

  1. Drew Baker
    Member
    Posted 5 years ago #

    I just posted this in a resolved thread. So here it is again in an unresolved thread. Admin please delete if this isn't correct.

    I'd like to remove the shortcodes from the_excerpt too. But I can't get it to work. Is my functions.php correct?

    <?php
    if ( function_exists('register_sidebar') )
    register_sidebar(array('name'=>'Main Sidebar',
            'before_widget' => '<li><div id="%1$s" class="%2$s">',
            'after_widget' => '</div></li>',
            'before_title' => '<h2 class="widgettitle">',
            'after_title' => '</h2>',
    		));
    register_sidebar(array('name'=>'Comments Sidebar',
            'before_widget' => '<li><div id="%1$s" class="%2$s">',
            'after_widget' => '</div></li>',
            'before_title' => '<h2 class="widgettitle">',
            'after_title' => '</h2>',
    		));
    register_sidebar(array('name'=>'Footer Sidebar',
            'before_widget' => '<li><div id="%1$s" class="%2$s">',
            'after_widget' => '</div></li>',
            'before_title' => '<h2 class="widgettitle">',
            'after_title' => '</h2>',
    		));
    add_filter('the_excerpt', 'do_shortcode');
    ?>

    Thanks for the help!

  2. RGlover
    Member
    Posted 5 years ago #

    Try This:

    <?php
    if ( function_exists('register_sidebar') ) {
    register_sidebar(array('name'=>'Main Sidebar',
            'before_widget' => '<li><div id="%1$s" class="%2$s">',
            'after_widget' => '</div></li>',
            'before_title' => '<h2 class="widgettitle">',
            'after_title' => '</h2>',
    		));
    register_sidebar(array('name'=>'Comments Sidebar',
            'before_widget' => '<li><div id="%1$s" class="%2$s">',
            'after_widget' => '</div></li>',
            'before_title' => '<h2 class="widgettitle">',
            'after_title' => '</h2>',
    		));
    register_sidebar(array('name'=>'Footer Sidebar',
            'before_widget' => '<li><div id="%1$s" class="%2$s">',
            'after_widget' => '</div></li>',
            'before_title' => '<h2 class="widgettitle">',
            'after_title' => '</h2>',
    		));
    }
    add_filter('the_excerpt', 'do_shortcode');
    ?>

    I added {} around the content of the if block. That way the add_filter() call isn't conditional upon register_sidebar. Hope that helps.

  3. Drew Baker
    Member
    Posted 5 years ago #

    Hey RGlover,
    Thanks so much for the help, but it didn't work. I've contacted the plugin author (Viper Videos) so maybe he can help.

    -Drew

Topic Closed

This topic has been closed to new replies.

About this Topic