WordPress.org

Ready to get started?Download WordPress

Forums

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

  1. nair
    Member
    Posted 6 years ago #

    Hi,

    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 . ')
                </ul>
              </div>';

    someone can helpe one more time?

    thanks!

  2. Adam Brown
    Member
    Posted 6 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">';
    
    wp_list_cats('optioncount=0&child_of=56&orderby=ID');
    
    echo '      </ul>
              </div>';
  3. moshu
    Member
    Posted 6 years ago #

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

  4. nair
    Member
    Posted 6 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