我正在尝试回显设置
$this->settings['numberofwordsexcerpt'] = array(
'title' => __( 'Number of Words' ),
'desc' => __( 'Please enter here the number of words you want the latest posts on index to have.' ),
'std' => '25',
'type' => 'text',
'section' => 'general'
);
在变量中进入这个函数$word_limit
add_action('the_excerpt','limit_the_content');
function limit_the_content($content){
$word_limit = $this->settings['numberofwordsexcerpt']; // HERE I AM TRYING to echo it
但是不起作用,我收到错误消息
Fatal error: Using $this when not in object context
$words = explode(' ', $content); return implode(' ', array_slice($words, 0, $word_limit)); }
我也试过
$word_limit = $settings['numberofwordsexcerpt'];
我得到一个与变量$settings
未定义有关的错误......也试过了
$word_limit = ?> <?php echo $settings['numberofwordsexcerpt']; ?>
并得到与尝试删除该错误相关的错误";",
,但错误仍然存在。请帮忙。