WP จำกัดตัวอักษรบทความ ที่แสดงหน้าแรก อย่างไร

เริ่มโดย 8x8x, 12 เมษายน 2012, 21:54:33

หัวข้อก่อนหน้า - หัวข้อถัดไป

0 สมาชิก และ 1 ผู้มาเยือน กำลังดูหัวข้อนี้

8x8x

WP จำกัดตัวอักษรในแต่ละบทความที่แสดงหน้าแรก อย่างไร
เช่นเราต้องการให้แสดงตัวอักษณแค่ 300 ตัว แล้ว มีปุ่ม Read More เอา

:wanwan017:

pongweb


luna_tea

ขอบคุณมากครับ เจอ theme ตัดให้บ้าง ไม่ตัดให้บ้างมานานแล้ว เพิ่งเจอวิธีแก้เนี่ย  :P

8x8x

ขอดันหน่อยครับ พอดีลองแล้วยังไม่ค่อยถูกใจ

มีตัวอื่นอีกมั๊ยครับ

ขอบคุณคุณ pongweb ด้วยครับ +1  :wanwan017:

ibombb

function custom_excerpt_length( $length ) {
return 20;
}
add_filter( 'excerpt_length', 'custom_excerpt_length', 999 );


หรืออ่านข้อมูลต่างๆได้ที่ http://codex.wordpress.org/Function_Reference/the_excerpt
ดีใจที่ได้ก้าวเท้ามานั่งเล่น tsb อีกรอบ

arafarn12

ผมใช้อันนี้ครับ

<a href="<?php the_permalink() ?>" title="<?php the_title(); ?>" >

<?php
$the_title = $post->post_title;
$getlength = strlen($the_title);
$thelength = 300;
echo substr($the_title, 0, $thelength);
if ($getlength > $thelength) ;
?>.. Read more.

</a>

จากธีม cTwentyten ของพี่ภัทรวุธ จันทร์งาม ครับ  :wanwan017:
เมพ เมพ เมพ บร๊ะมูลใหมล่ะ ?
ERROR: เขียนอะไรบ้างซิ