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

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

ThaiSEOBoard.comพัฒนาเว็บไซต์CMS & Free Script***รบกวนผู้รู้นิดนึงครับ ใครพอทราบโค้ด php มันไป get มาจากไฟล์ไหน
หน้า: [1]   ลงล่าง
พิมพ์
ผู้เขียน หัวข้อ: ***รบกวนผู้รู้นิดนึงครับ ใครพอทราบโค้ด php มันไป get มาจากไฟล์ไหน  (อ่าน 820 ครั้ง)
0 สมาชิก และ 1 บุคคลทั่วไป กำลังดูหัวข้อนี้
hastyman
ก๊วนเสียว
*

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

กระทู้: 252



ดูรายละเอียด
« เมื่อ: 04 พฤศจิกายน 2012, 00:11:03 »

ใครพอทราบโค้ด php ข้างล่างมันไป get มาจากไฟล์ไหน
โค้ดจาก theme ไฟล์ index.php
...
   <div class="story">
   <?php if ( !get_option('bmg_thumbnail')) {?>
   <?php get_thumbnail($post->ID); ?>   
   <?php } ?>
   <?php the_excerpt();?>
   </div>
...

คือผมต้องการแก้หน้า homepage ที่มันตัดคำแต่ละ post ให้มีคำว่า read more
แทน [...] และใส่ลิงค์เข้าไปด้วยครับ

รบกวนผู้รู้นิดนึงครับ


 wanwan004
« แก้ไขครั้งสุดท้าย: 04 พฤศจิกายน 2012, 00:20:26 โดย hastyman » บันทึกการเข้า
ball6847
เจ้าพ่อบอร์ดเสียว
*

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

กระทู้: 4,174



ดูรายละเอียด
« ตอบ #1 เมื่อ: 04 พฤศจิกายน 2012, 00:19:26 »

http://codex.wordpress.org/Fun...2read_more.22_link_to_the_post

ล่างๆครับ ลองทำตามดู เขียนไว้ใน functions.php ของ theme ครับ
บันทึกการเข้า

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

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

กระทู้: 971



ดูรายละเอียด เว็บไซต์
« ตอบ #2 เมื่อ: 04 พฤศจิกายน 2012, 00:20:50 »

http://codex.wordpress.org/Fun...2read_more.22_link_to_the_post

ล่างๆครับ ลองทำตามดู เขียนไว้ใน functions.php ของ theme ครับ


ตามนี้  wanwan016
บันทึกการเข้า

hastyman
ก๊วนเสียว
*

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

กระทู้: 252



ดูรายละเอียด
« ตอบ #3 เมื่อ: 04 พฤศจิกายน 2012, 02:35:59 »

http://codex.wordpress.org/Fun...2read_more.22_link_to_the_post

ล่างๆครับ ลองทำตามดู เขียนไว้ใน functions.php ของ theme ครับ


ใส่ไว้ Line ไหนครับ ดำน้ำแย่แล้ว

function new_excerpt_more($more) {
       global $post;
   return ' <a href="'. get_permalink($post->ID) . '">Read the Rest...</a>';
}
add_filter('excerpt_more', 'new_excerpt_more');

---------------

โค้ดจาก wp-includes 3.1.3 ไฟล์ post-template.php
/**
* Display the post excerpt.
 * @since 0.71
 * @uses apply_filters() Calls 'the_excerpt' hook on post excerpt.
 */

function the_excerpt() {
   echo apply_filters('the_excerpt', get_the_excerpt());
}

/**
 * Retrieve the post excerpt.
 * @since 0.71
 * @param mixed $deprecated Not used.
 * @return string
 */

function get_the_excerpt( $deprecated = '' ) {
   if ( !empty( $deprecated ) )
      _deprecated_argument( __FUNCTION__, '2.3' );

   global $post;
   $output = $post->post_excerpt;
   if ( post_password_required($post) ) {
      $output = __('There is no excerpt because this is a protected post.');
      return $output;
   }

   return apply_filters('get_the_excerpt', $output);
}

---------------------

โค้ดจาก theme ไฟล์ functions.php
function theme_add_admin() {

 global $themename, $shortname, $options;  

if ( $_GET['page'] == basename(__FILE__) ) {
   if ( 'bmg_update' == $_REQUEST['action'] ) {
      
      update_option('bmg_featured', $_REQUEST['bmg_featured']);
      update_option('bmg_featured_count', $_REQUEST['bmg_featured_count']);
      update_option('bmg_med_featured', $_REQUEST['bmg_med_featured']);
      update_option('bmg_tab_sb', $_REQUEST['bmg_tab_sb']);
      update_option('bmg_middle_sb', $_REQUEST['bmg_middle_sb']);
      update_option('bmg_bottom_sb', $_REQUEST['bmg_bottom_sb']);
      update_option('bmg_footer', $_REQUEST['bmg_footer']);
      update_option('bmg_thumbnail', $_REQUEST['bmg_thumbnail']);   
      
   }
   
}
 
   add_theme_page($themename." Options", "".$themename." Options", 'edit_themes', basename(__FILE__), 'theme_admin');
}
*

------------------

โค้ดจาก theme ไฟล์ index.php

   <div class="story">
   <?php if ( !get_option('bmg_thumbnail')) {?>
   <?php get_thumbnail($post->ID); ?>   
   <?php } ?>
   <?php the_excerpt();?>
   </div>
   <div class="tags"><small><?php the_tags( 'Tags: [', ', ', ']'); ?></small></div>   
   </div>
« แก้ไขครั้งสุดท้าย: 04 พฤศจิกายน 2012, 02:48:40 โดย hastyman » บันทึกการเข้า
ball6847
เจ้าพ่อบอร์ดเสียว
*

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

กระทู้: 4,174



ดูรายละเอียด
« ตอบ #4 เมื่อ: 04 พฤศจิกายน 2012, 08:03:00 »

ไฟล์ functions.php จะอยู่ในโฟลเดอร์ของ theme ครับ อยู่ที่เดียวกับไฟล์ index.php ของ theme นั่นแหละครับ เอาไว้ตรงไหนของไฟล์ก็ได้ แทรกไปด้านล่างก็ได้ ส่วนไฟล์ index.php ไม่ต้องไปแก้อะไรครับ
บันทึกการเข้า

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

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

กระทู้: 745



ดูรายละเอียด เว็บไซต์
« ตอบ #5 เมื่อ: 04 พฤศจิกายน 2012, 14:50:50 »

   <div class="story">
   <?php if ( !get_option('bmg_thumbnail')) {?>
   <?php get_thumbnail($post->ID); ?>   
   <?php } ?>
   <?php the_excerpt();?>
 
<div class="more"><a href="<?php the_permalink(); ?>">Read More..</a></div>

   </div>

เขียนแบบนี้ก็ได้ครับ แต่เวลาก่อนโพสต์บทความให้เราทำการตัดบทความก่อนนะครับ แต่ถ้าต้องการให้มันตัดบทความแบบ auto ก็เข้าไปแก้ใน functions.php ดังที่กล่าวไว้ในข้างต้นได้ครับ
บันทึกการเข้า

hastyman
ก๊วนเสียว
*

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

กระทู้: 252



ดูรายละเอียด
« ตอบ #6 เมื่อ: 04 พฤศจิกายน 2012, 22:34:22 »

ผมลองใส่ไว้ในไฟล์ fucntion แล้ว

แต่ theme มันเก่า อาจไม่แมตกับ Wordpress 3.1.3

ขอบคุณทั้ง 3 ท่านครับ



 wanwan017 wanwan017 wanwan017
บันทึกการเข้า
หน้า: [1]   ขึ้นบน
พิมพ์