我正在尝试回显设置
$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']; ?>
并收到与";",
尝试删除该错误相关的错误,仍然存在错误。请帮忙。
$settings = get_option('mytheme_options');
$word_limit = $settings['numberofwordsexcerpt'];
echo $word_limit;
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句