add code for a specified page
-
I just want a simple thing…
I want to add this code for “show last comments”
<?php $number=5; // number of recent comments desired $post_id = get_the_ID(); $comments = $wpdb->get_results("SELECT * FROM $wpdb->comments WHERE comment_post_ID=$post_id AND comment_approved = '1' ORDER BY comment_date_gmt DESC LIMIT $number"); ?> <ul id="recentcomments"> <?php if ($comments) : echo '<h2>' . sizeof($comments) . ' Recent Comments</h2>'; foreach ( (array) $comments as $comment) : echo '<li class="recentcomments">' . sprintf(__('%1$s on %2$s'), get_comment_author_link(), '<a href="'. get_comment_link($comment->comment_ID) . '">' . get_the_title($comment->comment_post_ID) . '</a>') . '</li>'; endforeach; endif;?> </ul> <!-- end of comments --> </div>
but I want this to take effect only in a specified page… for example
mysite.com/?page_id=4567
Can anybody help me??
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘add code for a specified page’ is closed to new replies.