สอบถามการตั้งค่า Wordpress ไม่ให้แสดงบทความทั้งหมดในหน้าแรกครับ

เริ่มโดย Aruviss, 02 มีนาคม 2013, 13:47:11

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

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

Aruviss

ทำยังไงให้ Wordpress ไม่แสดงบทความทั้งหมดในหน้าแรกอ่ะครับ

ให้แสดงแค่บางส่วนแล้วคลิกเข้าไปอ่านต่อในบทความอ่ะครับ


ขอบคุณล่วงหน้าครับ

inkz

ชีวิตต้องเดินต่อไป

ptteppawong


Serge

บางทีมของ WP~ ก็จะตัดบทความให้เองนะครับ แต่ส่วนใหญ่จะมีในทีมแบบ Premium  :P
[direct=http://xn--12c3c0ac0cf5ac2j5d2a.com/]Herbraga[/direct] ผลิตภัณฑ์เสริมอาหาร เหมาะสำหรับผู้ที่รักสุขภาพ

wasantec


Aruviss

อ้างถึงจาก: inkz ใน 02 มีนาคม 2013, 13:52:48
ใช้โค้ด <!--more--> กั้นไว้ครับ

อยากได้แบบใช้กับทุกโพสเลยอ่าครับ แหะๆ  :P


อ้างถึงจาก: ptteppawong ใน 02 มีนาคม 2013, 13:55:57
ใช้ plugin ตัวนี้  ติ๊กค่าไม่ให้มันโชว์หน้าแรก 

http://wordpress.org/extend/plugins/wp-hide-post/screenshots/

เว้บลูกค้าที่ผมทำให้
http://suanlamai.com/

อันนี้มันหายไปทั้ง post เลยอ่ะครับหรือผมตั้งค่าผิด

อ้างถึงจาก: wasantec ใน 02 มีนาคม 2013, 14:05:03
เขียนเอาครับ จะให้แสดงเยอะแค่ไหนก็ได้

ทราบครับว่าเขียนเอา แต่ไม่ทราบวิธีเขียนครับ

ptteppawong

ใช้ plugin ตัวนี้  ติ๊กค่าไม่ให้มันโชว์หน้าแรก 

http://wordpress.org/extend/pl...gins/wp-hide-post/screenshots/

อ้อ....ผมเข้าใจผิดนึกว่าไม่ให้แสดงที่หน้าแรก

ไฟล์ functions.php   เพิ่มโค้ดเหล่านี้ลงไป

function string_limit_words($string, $word_limit)
{
$words = explode(' ', $string, ($word_limit + 1));
if(count($words) > $word_limit)
array_pop($words);
return implode(' ', $words);
}


function excerpt($limit) {
  $excerpt = explode(' ', get_the_excerpt(), $limit);
  if (count($excerpt)>=$limit) {
    array_pop($excerpt);
    $excerpt = implode(" ",$excerpt).'...';
  } else {
    $excerpt = implode(" ",$excerpt);
  }
  $excerpt = preg_replace('`\[[^\]]*\]`','',$excerpt);
  return $excerpt;
}

function content($limit) {
  $content = explode(' ', get_the_content(), $limit);
  if (count($content)>=$limit) {
    array_pop($content);
    $content = implode(" ",$content).'...';
  } else {
    $content = implode(" ",$content);
  }
  $content = preg_replace('/\[.+\]/','', $content);
  $content = apply_filters('the_content', $content);
  $content = str_replace(']]>', ']]&gt;', $content);
  return $content;
}


หน้า index.php  แทีกโค้ดนี้ลงไป

<?php get_the_content_limit(150,''); ?>