หัวข้อ: ***รบกวนผู้รู้นิดนึงครับ ใครพอทราบโค้ด php มันไป get มาจากไฟล์ไหน เริ่มหัวข้อโดย: hastyman ที่ 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: หัวข้อ: Re: รบกวนผู้รู้นิดนึงครับ ใครพอทราบโค้ด php มันไป get มาจากไฟล์ไหน เริ่มหัวข้อโดย: ball6847 ที่ 04 พฤศจิกายน 2012, 00:19:26 http://codex.wordpress.org/Function_Reference/the_excerpt#Make_the_.22read_more.22_link_to_the_post
ล่างๆครับ ลองทำตามดู เขียนไว้ใน functions.php ของ theme ครับ หัวข้อ: Re: รบกวนผู้รู้นิดนึงครับ ใครพอทราบโค้ด php มันไป get มาจากไฟล์ไหน เริ่มหัวข้อโดย: Shiseido ที่ 04 พฤศจิกายน 2012, 00:20:50 [url]http://codex.wordpress.org/Function_Reference/the_excerpt#Make_the_.22read_more.22_link_to_the_post[/url] ล่างๆครับ ลองทำตามดู เขียนไว้ใน functions.php ของ theme ครับ ตามนี้ :wanwan016: หัวข้อ: Re: รบกวนผู้รู้นิดนึงครับ ใครพอทราบโค้ด php มันไป get มาจากไฟล์ไหน เริ่มหัวข้อโดย: hastyman ที่ 04 พฤศจิกายน 2012, 02:35:59 [url]http://codex.wordpress.org/Function_Reference/the_excerpt#Make_the_.22read_more.22_link_to_the_post[/url] ล่างๆครับ ลองทำตามดู เขียนไว้ใน 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> หัวข้อ: Re: ***รบกวนผู้รู้นิดนึงครับ ใครพอทราบโค้ด php มันไป get มาจากไฟล์ไหน เริ่มหัวข้อโดย: ball6847 ที่ 04 พฤศจิกายน 2012, 08:03:00 ไฟล์ functions.php จะอยู่ในโฟลเดอร์ของ theme ครับ อยู่ที่เดียวกับไฟล์ index.php ของ theme นั่นแหละครับ เอาไว้ตรงไหนของไฟล์ก็ได้ แทรกไปด้านล่างก็ได้ ส่วนไฟล์ index.php ไม่ต้องไปแก้อะไรครับ
หัวข้อ: Re: ***รบกวนผู้รู้นิดนึงครับ ใครพอทราบโค้ด php มันไป get มาจากไฟล์ไหน เริ่มหัวข้อโดย: rukrean ที่ 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 ดังที่กล่าวไว้ในข้างต้นได้ครับ หัวข้อ: Re: ***รบกวนผู้รู้นิดนึงครับ ใครพอทราบโค้ด php มันไป get มาจากไฟล์ไหน เริ่มหัวข้อโดย: hastyman ที่ 04 พฤศจิกายน 2012, 22:34:22 ผมลองใส่ไว้ในไฟล์ fucntion แล้ว
แต่ theme มันเก่า อาจไม่แมตกับ Wordpress 3.1.3 ขอบคุณทั้ง 3 ท่านครับ :wanwan017: :wanwan017: :wanwan017: |