简体   繁体   中英

How to put an echo inside a div that's inside an echo

I am trying to call Buddy Press' avatar and replace my Newspaper theme's avatar in the menu. How do I put this code:

    echo bp_core_fetch_avatar( array(
        'item_id' => bp_loggedin_user_id(),
        'width' => 21,
        'height' => 21,
        'class' => 'avatar',
        )
    );

Inside the

    <div class="td-avatar-container"></div>

class?

   <?php

    //get current logd in user data

    global $current_user;

    echo '
    <div class="td-logged-wrap">
            <div class="td-menu-avatar">
                 <div class="td-avatar-container">' .   bp_core_fetch_avatar ($current_user->ID, 80) .  '</div>
            </div>

    <div class="td-menu-username"><a href="' . bp_core_get_user_domain($current_user->ID) . '" class="td_user_logd_in">' . $current_user->display_name . '</a></div>
    <div class="td-menu-logout"><a href="' . wp_logout_url(home_url( '/' )) . '">' . __td('Logout', TD_THEME_NAME) . '</a></div>
</div>
    ';

Thanks! I keep getting white screens, and this is the very last thing I need for this feature to go live! Any help would be greatly appreciated.

You can stop and start PHP within html any time.

<div class="td-logged-wrap">
  <div class="td-menu-avatar">
        <div class="td-avatar-container">

        <?php echo' .   bp_core_fetch_avatar ($current_user->ID, 80) .  '; ?>

        </div>
  </div>

<div class="td-menu-username"><a href="

<?php echo' . bp_core_get_user_domain($current_user->ID) . '; ?>

" class="td_user_logd_in"><?php echo' . $current_user->display_name . '; ?>

</a></div>

<div class="td-menu-logout"><a href="<?php echo' . wp_logout_url(home_url( '; ?> / <?php echo' )) . '; ?>"><?php echo' . __td('; ?>Logout<?php echo', TD_THEME_NAME) . '; ?></a>
</div>

This doesn't quite answer your question, but will help you see why you are having the problem. Change the following in the wp-config.php in order to see the errors and you can debug from there: define('WP_DEBUG', true);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM