-1

サイトの作成者をjqueryカルーセルに表示しようとしていますが、何らかの理由で画像がliタグなしで出力され、理由がわかりません。

コード

functions.php

function contributors() {
    global $wpdb;

    $authors = $wpdb->get_results("SELECT ID, user_nicename from $wpdb->users ORDER BY display_name");

    foreach($authors as $author) {
        // display user image for each author
        echo '<li class="author" id="author-'.$author->ID.'">'.userphoto($author->ID).'</li>';
    }
}

テンプレートファイル

<?php while ( have_posts() ) : the_post(); ?>

    <div id="authorlist"><ul id="authorcarousel"><?php contributors(); ?></ul></div>

<?php endwhile; // end of the loop. ?>

出力

<div id="authorlist">
    <ul id="authorcarousel">
        <img src="/wordpress/wp-content/uploads/userphoto/1.jpg" alt="admin" width="143" height="150" class="photo" />
        <li class="author" id="author-1"></li>
        <img src="/wordpress/wp-content/uploads/userphoto/3.png" alt="" width="128" height="128" class="photo" />
        <li class="author" id="author-3"></li>
        <img src="/wordpress/wp-content/uploads/userphoto/2.png" alt="" width="128" height="128" class="photo" />
        <li class="author" id="author-2"></li>
    </ul>
</div>

目指しているのは、liタグ間に出力する画像です。

誰かが答えを知っている場合のボーナス質問 - サイト管理者ではなく作成者のみが表示されるようにクエリを編集するにはどうすればよいですか? クエリに句を追加しようとしましたWHEREが、うまくいきませんでした。

私はWordPressのn00bであるため、どんな助けも大歓迎です.

4

1 に答える 1

1

このuserphoto関数は、画像 HTML を返すのではなくエコーします。だから、次のようなものを試してください:

foreach($authors as $author) {
    echo '<li class="author" id="author-'.$author->ID.'">';
    userphoto($author->ID);
    echo '</li>';
}
于 2012-07-23T17:06:35.847 に答える