[resolved] help to solve echo php Incorrect concatenation (4 posts)

  1. nair
    Posted 7 years ago #


    yesterday in this forum you guys helped me to solve this problem: topic 157771

    and today i thought that i could solve this:

    } elseif ( (in_category('56')) {
    echo 	'<div id="submenu">
                <ul class="fix">
    wp_list_cats(' . optioncount=0&child_of=56&orderby=ID . ')

    someone can helpe one more time?


  2. Adam Brown
    Posted 7 years ago #

    Might I suggest this:

    easy php tutorial for WP users

    wp_list_cats() is PHP, not HTML. You need to break out of the apostrophes to switch from a string (HTML) to a PHP command and then back to a string.

    In general:

    echo 'html html html' . php . 'html html html';

    In specific:

    echo '<div>...<ul>...' . wp_list_cats('query') .'...</ul></div>';

    You are concatenating (connecting) a string <div>...<ul>... to a PHP command wp_list_cats() to another string ...</ul></div>.

    Maybe it would be more obvious what's going on if I wrote your code like this:

    } elseif ( (in_category('56')) {
    echo 	'<div id="submenu">
                <ul class="fix">';
    echo '      </ul>
  3. moshu
    Posted 7 years ago #

    That's a neat little tutorial, Adam!
    Bookmarked :)

  4. nair
    Posted 7 years ago #

    thanks a lot adamrbrown for all this great information for me to study!

    it works, problem solved :)

    thanks again!

Topic Closed

This topic has been closed to new replies.

About this Topic