开发者

how to remove thumbnail from the wordpress the_excerpt function?

I have the following situation:

<?php query_posts('page_id=2'); ?>
        <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
        <div class="post" id="post-<?php the_ID(); ?>">
            <h2><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></h2>
            <div class="entry">
                <p><?php the_excerpt(); ?></p>
            </div>
            <?php endwhile; else : ?>
            <?php endif; ?>
            <?php wp_reset_query(); ?>

But also i am using the "Advanced Excerpt" plugin, which extract the thumbnail for an excerpt. How can i remove the default thumbnail extracted by the "the_excerpt();" function? I want only the "Advanced Excerpt" plugin to handle excerpt thumbnails, so no duplica开发者_Python百科ted thumbnails will have.


Short answer: Advanced Excerpt allows you to use their the_advanced_excerpt() function with certain parameters, including the ability to strip any html tags (img included), so try this instead of the_excerpt() :

the_advanced_excerpt('exclude_tags=img');

Long answer: A lot of missing info in your question: are you entering text into the manual excerpt field in the post edit, or are you depending on Advanced Excerpt to automatically take the first 55 characters (the wordpress default) of the post as the excerpt? If no manual excerpt is specificed the_excerpt() will automatically grab the first 55 characters and strip any html tags or graphics

source: http://codex.wordpress.org/Template_Tags/the_excerpt

In either case, are you placing an image in the first 55 characters of your posts?

"Can I manually call the filter in my WP templates, for example? The plugin automatically hooks on the_excerpt() function and uses the parameters specified in the options panel.

If you want to call the filter with different options, you can use the_advanced_excerpt() template tag provided by this plugin. This tag accepts query-string-style parameters (theme developers will be familiar with this notation).

The following parameters can be set:

length, an integer that determines the length of the excerpt

use_words, if set to 1, the excerpt length will be in words; if set to 0, characters will be used for the count

no_custom, if set to 1, an excerpt will be generated even if the post has a custom excerpt; if set to 0, the custom excerpt will be used

no_shortcode, if set to 1, shortcodes are removed from the excerpt; if set to 0, shortcodes will be parsed

ellipsis, the string that will substitute the omitted part of the post; if you want to use HTML entities in the string, use %26 instead of the & prefix to avoid breaking the query

read_more, the text used in the read-more link

add_link, if set to 1, the read-more link will be appended; if 0, no link will be added

allowed_tags, a comma-separated list of HTML tags that are allowed in the excerpt. Entering _all will preserve all tags.

exclude_tags, a comma-separated list of HTML tags that must be removed from the excerpt. Using this setting in combination with allowed_tags makes no sense"

source: http://wordpress.org/extend/plugins/advanced-excerpt/faq/

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜