Support » How-To and Troubleshooting » [Resolved] New to writing Shortcodes

[Resolved] New to writing Shortcodes

  • Hi dont know if anyone can put me right – a probably a newbie stupid error but…
    writing a shortcode to list child categories based on the name of the page which implements a category and has the same name.
    In this case the Page name is Destinations which is also the name of a top level category.

    function AB_handler_get_child_cats($atts){
        $cat = get_cat_ID($category_name);
        if( $cat > 0 ){
                        'show_count' => "0",
                        'orderby' =>"name",
                    ), $atts));
            $this_category = get_category($cat);
            if (get_category_children($this_category->cat_ID) != "") {
                $html = "<div><ul>";
                $html .= "</ul></div>";
            return $html;

    If I put the following [childcats] or [childcats show_count=1 orderby=’name’] in a text widget titled “Destinations” the output is being rendered prior to the start of the widget border (outside the border).

    What am I doing wrong?

Viewing 6 replies - 1 through 6 (of 6 total)
  • It looks like you are missing the


    parameter in wp_list_categories.



    Forum Moderator


    $html = "<div><ul>";
     $html .= wp_list_categories("echo=0&orderby=$orderby&show_count=$show_count&title_li=&use_desc_for_title=1&child_of=".$this_category->cat_ID);
    $html .= "</ul></div>";

    Thanks for coming back to me guys.
    However including echo=0 now, as would seem intuitive, is not echoing anything. Its now not rendering any list at all. Previously it was the correct output just in the wrong place.



    Forum Moderator

    have you read my reply with the suggested changes after adding the ‘echo=0’ ?

    Aha Yes I did read it but clearly I missed the $html assignment. Much appreciated your spot on.



Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘[Resolved] New to writing Shortcodes’ is closed to new replies.