• This really simple shortcode function is stopping the AddThis buttons from showing…

    function mwe_rtr_do_shortcode_2() {
    
        $args = array(
            'post_type' => 'mwe_rtr', //my custom post type
            'posts_per_page' => -1,
            'order' => 'ASC',
            'order_by' => 'date'
        );
        $loop = new WP_Query( $args );
    
        //loop through custom post types
        while ( $loop->have_posts() ) : $loop->the_post();
            //do nothing
        endwhile;
    
        return 'Only if the above while loop is removed will the AddThis buttons be shown on any page that uses this [mwe_rtr_2] shortcode!';
    }
    add_shortcode( 'mwe_rtr_2', 'mwe_rtr_do_shortcode_2' );

    It’s the presence of the while loop in my code that is causing the AddThis buttons not to show.

    This seems like a bug with AddThis, so can someone solve or advise?

    Thanks in advance,
    James

    PS – All my plugins are up-to-date and I have set WP_DEBUG to TRUE in wp-config.php, but no clues are outputted as to the problem.

    https://www.ads-software.com/plugins/addthis/

Viewing 10 replies - 1 through 10 (of 10 total)
Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘Buttons not showing when page includes a shortcode with custom post type loop’ is closed to new replies.