Shortcode Exec PHP
List Categories (3 posts)

  1. Naz
    Posted 5 years ago #

    The wp_list_categories tag and the the_tags tag don't appear to work with the Shortcode Exec PHP plugin.

    I get the following message when I click the 'Test' button:


    Unexpected output, do not use ECHO but RETURN

    When I use the following code (the list_categories shortcode uses the wp_list_categories tag) the list with categories actually shows up above the 'Categories' header.


    I used the following code for the [list_tags] shortcode:


    The tags don't show up at all.

    Thanks in advance for your help!

  2. Michael
    Forum Moderator
    Posted 5 years ago #

    wp_list_categories() echoes (directly outputs) the list, unless you set the 'echo' paarameter to 'false'

    as for the_tags() http://codex.wordpress.org/Function_Reference/the_tags
    it might be that the connection to the loop is lost where it is called;
    try to add global $post; before the line.
    anyway, it outputs/displays the results immediately, which makes it unsuitable to use in a shortcode -
    consider working with http://codex.wordpress.org/Function_Reference/get_the_tags

  3. Naz
    Posted 5 years ago #

    I fixed the wp_list_categories() by making sure 'Output Echoed' was checked.

    I used the wp_tag_cloud() tag for the tags. Oops!

    I just recently moved the site and my old shortcodes were lost (I have a question: are the shortcodes saved somewhere in the database? I can't find them), so I guess I did something wrong when I recreated the shortcodes. :)

    Thanks for your help!

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic