2014-08-28 68 views
0

又需要一點點的幫助,這裏是WordPress中恢復文本內容和更多的鏈接的功能:限制字符以12字函數Php

function whisper_entry_contentoffer1() 
{ 
global $whisper; 

// Check on singular pages 
$is_single = is_singular() && !is_page_template('tpl/blog.php') && !is_page_template('tpl/blog-boxes.php'); 

// Allow to config via global variable 
if (isset($whisper['is_single'])) 
    $is_single = $whisper['is_single']; 

if ($is_single) 
{ 
    echo '<div class="entry-content">'; 
    the_content(); 
    wp_link_pages(array(
     'before'  => '<p class="pages">' . __('Pages:', 'whisper'), 
     'after'  => '</p>', 
     'link_before' => '<span>', 
     'link_after' => '</span>', 
    )); 
    echo '</div>'; 
    return; 
} 

// Archives & Blog pages 

// Display type 
$display = fitwp_option('blog_display'); 

// Allow to config via global variable 
if (isset($whisper['blog_display'])) 
    $display = $whisper['blog_display']; 

if (!$display) 
    $display = 'content'; 

echo '<div class="entry-summary">'; 

// Excerpt 
if ('excerpt' == $display) 
{ 
    the_excerpt(); 
    return; 
} 

$more_text = whisper_more_text2(); 

// Post content before more tag 
if ('more' == $display) 
{ 
    if (is_page_template('tpl/blog.php') || is_page_template('tpl/blog-boxes.php')) 
    { 
     global $more; 
     $more = false; 
    } 

    the_content($more_text); 
    wp_link_pages(array(
     'before'  => '<p class="pages">' . __('Pages:', 'whisper'), 
     'after'  => '</p>', 
     'link_before' => '<span>', 
     'link_after' => '</span>', 
    )); 
} 
else 
{ 
    whisper_content_limitoffer1(whisper_content_length(), $more_text); 
} 

echo '</div>'; // .entry-summary 
} 

現在我需要輸出文本限制在12個字。任何建議或靈魂?!

謝謝...

+0

可能重複[Function to Limit Words,然後顯示左邊的文字](http://stackoverflow.com/questions/12197756/function-to-limit-words-then-展會 - 左超文本) – 2014-08-28 13:20:21

回答

0

This?用你的字符串替換$ string

echo implode(" ",array_splice(explode(" ",$string),0,20));