Support » Fixing WordPress » [shortcodes] problem with $atts

  • Obviously something here is not correct but I just cant see it any help appreciated.

    The code is executing as it should accept that immediately after entry to ABNet_handler_blogs_newest(), inspection is showing a null terminated string for $atts. Why would the params not be passed to the handler?

    [netblogsnewest count=2 total=true]

    add_action("after_setup_theme", "ABNet_handler_blogs_newest", 15);
    
    add_shortcode('netblogsnewest','ABNet_handler_blogs_newest');
    
    function ABNet_handler_blogs_newest( $atts ) {
        if( !is_multisite() ) return false;
    
        extract( shortcode_atts( array(
                    'count' => '',
                    'total' => '',
               ), $atts )
         );
         return ABNet_output_blogs_newest($count, $total);
    
    }
Viewing 2 replies - 1 through 2 (of 2 total)
  • Moderator keesiemeijer

    (@keesiemeijer)

    moderator

    Not sure but why do you use the after_setup_theme action hook for this? I don’t think it’s needed.

    keesiemeijer – I am sure you are correct that it is not required – a lack of understanding on my part and not enough time to scrutanise every aspect of examples drawn upon. I have been including this construct for all shortcodes as it seemed to be required on the first that I did, and it has never caused obstruction since.

    Please feel free to enlighten me about its purpose.

    Removing it has made no difference to this not working of course.

    Andy

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘[shortcodes] problem with $atts’ is closed to new replies.