Excerpt post wordpress

0

What's wrong? I did the function to give excerpt in the posts of wordpress and import to another site, however it is not cutting with what I defined.

Can anyone give a light?

<?php while (have_posts()): the_post(); ?>
                    <div class="moldG">
                        <div class="thumbsG">
                            <?php the_post_thumbnail( array(300,266) ); ?>
                        </div>
                    </div>
                    <div class="wptexto">
                            <a class="blog" href="<?php the_permalink(); ?>" target="_blank"><?php the_title(); ?></a>
                            <?php the_excerpt(); 
                             if ( is_category() || is_archive() ) {
                                    the_excerpt();
                                    } 
                           function new_excerpt_length($length) {
                               return 240;
                               }
            endwhile; ?>
                    </div>  
                </div>
    
asked by anonymous 10.02.2015 / 20:49

1 answer

2

This is not how this filter is used. First you must declare the function new_excerpt_length in functions.php of your theme and then add as excerpt_length filter.

function new_excerpt_length($length) {
    return 240;
}
add_filter('excerpt_length', 'new_excerpt_length');

After that the size of the summary returned by the_excerpt() will be a maximum of 240 words throughout the site.

    
10.02.2015 / 20:55