WordPress.org

Ready to get started?Download WordPress

Forums

Post UI Tabs
Problems with shortcode, accordian not working, tabs unpredictable. (2 posts)

  1. belindajohnstone
    Member
    Posted 9 months ago #

    Hi, I'm having issues with the shortcodes.

    First I had paragraph tags appearing around all the shortcodes, and I was forever deleting them, and any spaces between the different shortcodes, and sometimes the tabs would show correctly, but it was a lot of back and forth and a fluke to get them to work.

    Then I added some sections of code I found to my functions.php

    /*remove paragraph around images----------------------------*/ 
    
        function filter_ptags_on_images($content){
       return preg_replace('/<p>\s*(<a .*>)?\s*(<img .* \/>)\s*(<\/a>)?\s*<\/p>/iU', '\1\2\3', $content);
    }
    add_filter('the_content', 'remove_empty_p', 20, 1);
    function remove_empty_p($content){
    $content = force_balance_tags($content);
    return preg_replace('#<p>\s*+(<br\s*/*>)?\s*</p>#i', '', $content);
    }
    
    //Clean Up WordPress Shortcode Formatting - important for nested shortcodes
    //adjusted from http://donalmacarthur.com/articles/cleaning-up-wordpress-shortcode-formatting/
    function parse_shortcode_content( $content ) {
    
       /* Parse nested shortcodes and add formatting. */
        $content = trim( do_shortcode( shortcode_unautop( $content ) ) );
    
        /* Remove '' from the start of the string. */
        if ( substr( $content, 0, 4 ) == '' )
            $content = substr( $content, 4 );
    
        /* Remove '' from the end of the string. */
        if ( substr( $content, -3, 3 ) == '' )
            $content = substr( $content, 0, -3 );
    
        /* Remove any instances of ''. */
        $content = str_replace( array( '<p></p>' ), '', $content );
        $content = str_replace( array( '<p>  </p>' ), '', $content );
    
        return $content;
    }
    
    //move wpautop filter to AFTER shortcode is processed
    remove_filter( 'the_content', 'wpautop' );
    add_filter( 'the_content', 'wpautop' , 99);
    add_filter( 'the_content', 'shortcode_unautop',100 );

    So my accordian test no longer has the extra paragraph tags, but won't seem to include the wrap part of the shortcode so won't work.

    and on this test (right column) the first shortcode seems to keep disappearing and the second stays in? (This is in a custom field using the ACT plugin).

    But here, also using 2 ACF fields, I have manage to get both the accordian and the tabs working... now I just wish I could make it happen again.

    Any ideas on what could be happening.

    Thanks,

    Belinda

    http://wordpress.org/extend/plugins/put/

  2. Mark / t31os
    Moderator
    Plugin Author

    Posted 8 months ago #

    Please feel free to update this thread if you still require some help.

    NOTE: Sorry for the delayed response, not had alot of time infront of the coding PC due to the hot weather we've been experiencing here in the UK(it's been pretty unbearable to be honest).

Reply

You must log in to post.

About this Plugin

About this Topic