• 功能:將迴響與引用分開,wordpress預設會將引用過來的文章也參雜在迴響裡
    2008-06-15_154940 (by vsy)
  • 難度:***
  • 參考網址

  1. 打開目前使用中的佈景主題裡的comments.php,裡面長得像這樣
    <?php if($comments) : ?>
    <ol>
        <?php foreach($comments as $comment) : ?>
            <li id="comment-<?php comment_ID(); ?>">
                <?php if ($comment->comment_approved == "0") : ?>
                <p>Your comment is awaiting approval</p>
            <?php endif; ?>
            <?php comment_text(); ?>
                <cite><?php comment_type(); ?> by <?php comment_author_link(); ?> on <?php comment_date(); ?> at <?php comment_time(); ?></cite>
            </li>
        <?php endforeach; ?>
    </ol>
    <?php else : ?>
        <p>No comments yet</p>
    <?php endif; ?>
    

    找到

    <?php foreach($comments as $comment) : ?>

    在他後面加入

    <?php if(get_comment_type() == “comment”) : ?>
  2. 找到
    <?php endforeach; ?>

    在他前面加入

    <?php endif; ?>

    這樣就把引用的部份隱藏了,現在只會顯示出迴響,還沒結束喔,如果你要讓引用單獨顯示,那就要繼續做下面步驟

  3. 在剛剛那段前面(將引用顯示在留言之前)或者後面(將引用顯示在留言之後),加入
    <?php if($comments) : ?>
    <ol>
        <?php foreach($comments as $comment) : ?>
            <?php if((get_comment_type() == “pingback”) || (get_comment_type() == “trackback”)) : ?>
                <li id=”comment-<?php comment_ID(); ?>”>
                    <?php comment_author_link() ?></li>
                </li>
            <?php endif; ?>
        <?php endforeach; ?>
    </ol>
    <?php endif; ?>
    

這樣就完成啦!

Popularity: 6% [?]