I am trying to echo setting
$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'
);
into this function in variable $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
BUT doesn’t work, I get the error
Fatal error: Using $this when not in object context
$words = explode(' ', $content); return implode(' ', array_slice($words, 0, $word_limit)); }
I also tried with
$word_limit = $settings['numberofwordsexcerpt'];
And i get an error related to the fact that the variable $settings
is not defined…
Also tried
$word_limit = ?> <?php echo $settings['numberofwordsexcerpt']; ?>
and get an error related to ";",
tried deleting that and still error remains. Please help.
1 comment