【发布时间】:2014-09-02 19:14:18
【问题描述】:
这是我的代码:
add_filter("the_content", "plugin_myContentFilter", "tie_excerpt_home_length");
function plugin_myContentFilter($content)
{
$content = preg_replace("/<img[^>]+\>/i", "(kép)", $content);
// Take the existing content and return a subset of it
return substr($content, 0, 300);
}
我想看到这个功能只在主页上工作。但不幸的是,这段代码无处不在(帖子、页面),并且不能显示全部内容。
这是应该反映在主页内容中的代码:
<li <?php tie_post_class('first-news'); ?>>
<div class="inner-content">
<?php if ( function_exists("has_post_thumbnail") && has_post_thumbnail() ) : ?>
<div class="post-thumbnail">
<a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'tie' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark">
<?php tie_thumb( 'tie-medium' ); ?>
<span class="overlay-icon"></span>
</a>
</div><!-- post-thumbnail /-->
<?php endif; ?>
<h2 class="post-box-title"><a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'tie' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php the_title(); ?></a></h2>
<?php get_template_part( 'includes/boxes-meta' ); ?>
<div class="entry">
<?php if($_eventcat) the_content(); else tie_excerpt_home() ?>
<a class="more-link" href="<?php the_permalink() ?>"><?php _e( 'Tovább >', 'tie' ) ?></a>
</div>
</div>
</li>
【问题讨论】:
标签: php wordpress function show