ยินดีต้อนรับคุณ, บุคคลทั่วไป กรุณา เข้าสู่ระบบ หรือ ลงทะเบียน

เข้าสู่ระบบด้วยชื่อผู้ใช้ รหัสผ่าน และระยะเวลาในเซสชั่น

ThaiSEOBoard.comพัฒนาเว็บไซต์CMS & Free Scriptใครเก่งเรื่องธีม wordpress ช่วยหน่อยครับ
หน้า: [1]   ลงล่าง
พิมพ์
ผู้เขียน หัวข้อ: ใครเก่งเรื่องธีม wordpress ช่วยหน่อยครับ  (อ่าน 962 ครั้ง)
0 สมาชิก และ 1 บุคคลทั่วไป กำลังดูหัวข้อนี้
moooaunna
คนรักเสียว
*

พลังน้ำใจ: 0
ออฟไลน์ ออฟไลน์

กระทู้: 195



ดูรายละเอียด เว็บไซต์
« เมื่อ: 27 มกราคม 2008, 00:28:39 »

อยากได้โค๊ด Sidebar ที่ใส่ได้ Recent Comments ที่ธีมมันมีแต่ Recent Post จะไปใช้ Wigets ตัวฟอนท์มันก็ไม่เหมือนกันนะ รบกวนช่วยแนะนำทีครับ

โค๊ดที่ใช้เขียน Recent Post
โค๊ด:
<strong>Recent Posts</strong>
<ul>
<?php global $post$posts get_posts('numberposts=10'); foreach($posts as $post){ ?>
<li><a href= "<?php the_permalink(); ?>"><?php the_title(); ?> </a></li>
<?php ?>
</ul>

โค๊ดที่ใช้เขียน Comments
โค๊ด:
<?php // Do not delete these lines
if ('comments.php' == basename($_SERVER['SCRIPT_FILENAME']))
die ('Please do not load this page directly. Thanks!');

if (!empty($post->post_password)) { // if there's a password
if ($_COOKIE['wp-postpass_' COOKIEHASH] != $post->post_password) {  // and it doesn't match the cookie
?>


<p class="nocomments">This post is password protected. Enter the password to view comments.</p>

<?php
return;
}
}

/* This variable is for alternating comment background */
$oddcomment 'class="alt" ';
?>


<!-- You can start editing here. -->

<?php if ($comments) : ?>
<h3 id="comments"><?php comments_number('No Responses''One Response''% Responses' );?> to &#8220;<?php the_title(); ?>&#8221;</h3>

<div class="commentlist">

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

<span <?php echo $oddcomment?>id="comment-<?php comment_ID() ?>">
<cite><?php comment_author_link() ?></cite> Says:
<?php if ($comment->comment_approved == '0') : ?>
<em>Your comment is awaiting moderation.</em>
<?php endif; ?>
<br />

<span class="column span-4 border">
<small class="commentmetadata"><a href="#comment-<?php comment_ID() ?>" title=""><?php comment_date('F jS, Y'?> at <?php comment_time() ?></a> <?php edit_comment_link('edit','&nbsp;&nbsp;',''); ?></small>
</span>

<span class="column span-8 last">

<?php comment_text() ?>
</span>
</span>
<hr />
<?php
/* Changes every other comment to a different class */
$oddcomment = ( empty( $oddcomment ) ) ? 'class="alt" ' '';
?>


<?php endforeach; /* end for each comment */ ?>

</div>

 <?php else : // this is displayed if there are no comments so far ?>

<?php if ('open' == $post->comment_status) : ?>
<!-- If comments are open, but there are no comments. -->

<?php else : // comments are closed ?>
<!-- If comments are closed. -->
<p class="nocomments">Comments are closed.</p>

<?php endif; ?>
<?php endif; ?>


<?php if ('open' == $post->comment_status) : ?>

<h3 id="respond">Leave a Reply</h3>

<?php if ( get_option('comment_registration') && !$user_ID ) : ?>
<p>You must be <a href="<?php echo get_option('siteurl'); ?>/wp-login.php?redirect_to=<?php the_permalink(); ?>">logged in</a> to post a comment.</p>
<?php else : ?>

<form action="<?php echo get_option('siteurl'); ?>/wp-comments-post.php" method="post" id="commentform">

<?php if ( $user_ID ) : ?>

<p>Logged in as <a href="<?php echo get_option('siteurl'); ?>/wp-admin/profile.php"><?php echo $user_identity?></a>. <a href="<?php echo get_option('siteurl'); ?>/wp-login.php?action=logout" title="Log out of this account">Logout &raquo;</a></p>

<?php else : ?>

<p><input type="text" name="author" id="author" value="<?php echo $comment_author?>" size="22" tabindex="1" />
<label for="author"><small>Name <?php if ($req) echo "(required)"?></small></label></p>

<p><input type="text" name="email" id="email" value="<?php echo $comment_author_email?>" size="22" tabindex="2" />
<label for="email"><small>Mail (will not be published) <?php if ($req) echo "(required)"?></small></label></p>

<p><input type="text" name="url" id="url" value="<?php echo $comment_author_url?>" size="22" tabindex="3" />
<label for="url"><small>Website</small></label></p>

<?php endif; ?>

<!--<p><small><strong>XHTML:</strong> You can use these tags: <code><?php echo allowed_tags(); ?></code></small></p>-->

<p><textarea name="comment" id="comment" cols="100%" rows="10" tabindex="4"></textarea></p>

<p><input name="submit" type="submit" id="submit" tabindex="5" value="Submit Comment" />
<input type="hidden" name="comment_post_ID" value="<?php echo $id?>" />
</p>
<?php do_action('comment_form'$post->ID); ?>

</form>

<?php endif; // If registration required and not logged in ?>

<?php endif; // if you delete this the sky will fall on your head ?>

ถ้าจะเอามาเขียน Recent Comments ต้องเขียนอย่างไรครับ
บันทึกการเข้า

daydies
หัวหน้าแก๊งเสียว
*

พลังน้ำใจ: 42
ออฟไลน์ ออฟไลน์

กระทู้: 1,327



ดูรายละเอียด เว็บไซต์
« ตอบ #1 เมื่อ: 27 มกราคม 2008, 00:34:38 »

วิธีการมันอยู่ที่บล็อกนี้ครับ ติดตั้งปลั๊กอิน จากนั้นจะใช้ความสามารถของ Widgets หรือว่าจะยัดฟังก์ชันลง Theme หรือจะยังไงก็ตามแต่ รายละเอียดครบ

โค๊ด:
http://blog.jodies.de/archiv/2004/11/13/recent-comments/
บันทึกการเข้า
moooaunna
คนรักเสียว
*

พลังน้ำใจ: 0
ออฟไลน์ ออฟไลน์

กระทู้: 195



ดูรายละเอียด เว็บไซต์
« ตอบ #2 เมื่อ: 27 มกราคม 2008, 01:03:12 »

วิธีการมันอยู่ที่บล็อกนี้ครับ ติดตั้งปลั๊กอิน จากนั้นจะใช้ความสามารถของ Widgets หรือว่าจะยัดฟังก์ชันลง Theme หรือจะยังไงก็ตามแต่ รายละเอียดครบ

โค๊ด:
http://blog.jodies.de/archiv/2004/11/13/recent-comments/


ขอบคุณที่แนะนำครับ พอดีใช้ Widgets ทำแล้วมันตัวหนังสือไม่สวย ไม่อยากไปแก้ที่อื่น ติดปัญหาอยู่ตรงที่เดียวแหละจะยัดลงไปใน Sidebar ให้มันมีครบสมบูรณ์ทั้งหมด เท่านั้นเองครับ พอดีไม่รู้เรื่องโค๊ด php ด้วยเลยงงเขียนไม่ถูก
บันทึกการเข้า

Newbies
สมุนแก๊งเสียว
*

พลังน้ำใจ: 42
ออฟไลน์ ออฟไลน์

กระทู้: 554



ดูรายละเอียด
« ตอบ #3 เมื่อ: 27 มกราคม 2008, 03:38:11 »

เจอฟังก์ชั่นใน theme หลายๆ ตัวครับ

โค๊ด:
// Recent Comments with Gravatars
function recent_cmts($num) {
global $wpdb;
$query = ("SELECT ID, post_title, comment_author, comment_id, comment_author_email, comment_date, comment_post_ID FROM  $wpdb->posts, $wpdb->comments WHERE $wpdb->posts.ID=$wpdb->comments.comment_post_ID AND $wpdb->comments.comment_approved = '1' AND $wpdb->comments.comment_type = '' AND comment_author != '' ORDER BY $wpdb->comments.comment_date DESC LIMIT $num");
$result = mysql_query($query);
while ($data = mysql_fetch_row($result)) {
echo '<li class="recent-cmts">';
echo '<img style="float: left; margin-right: 10px; padding: 3px; background: #EEE; border: 1px solid #CCC;" src="http://www.gravatar.com/avatar.php?gravatar_id=';
echo md5($data[4]);
echo '&amp;size=24&amp;default=';
echo bloginfo('template_url');
echo '/images/default_24.gif';
echo '" alt="';
echo $data[2];
echo '&#39;s Gravatar" height="24" width="24" class="recent_gravatars" />';
echo '<div style="margin-left: 42px;"><a href="';
echo get_permalink($data[0]);
echo "#comment-$data[3]";
echo '" title="';
echo 'commented on &raquo; ';
echo $data[1];
echo '"><strong>';
echo $data[2];
echo '</strong></a><br/>';
echo $data[5];
echo '</div>';
echo '</li>';
}
}

เอาไปดัดแปลงดู
บันทึกการเข้า



หน้า: [1]   ขึ้นบน
พิมพ์