Wordpress仅在主页上使用functions.php运行函数

Wordpress仅在主页上使用functions.php运行函数,php,wordpress,function,show,Php,Wordpress,Function,Show,这是我的密码: 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

这是我的密码:

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);
  }
add_filter(“内容”、“插件”myContentFilter、“链接摘录”home_length”);
函数插件\u myContentFilter($content)
{
$content=preg\u replace(“/]+\>/i”,“(kép)”,$content);
//获取现有内容并返回其子集
返回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>



添加检查主页的条件
is_home()
检查它是否是博客文章索引,
is_front_page()
检查它是否是frontpage(博客文章或静态页面)

if(is_home()| | is_front_page()){
添加过滤器(“内容”、“插件内容过滤器”、“链接摘录”主页长度);
}
函数插件\u myContentFilter($content)
{
$content=preg\u replace(“/]+\>/i”,“(kép)”,$content);
//获取现有内容并返回其子集
返回substr($content,0,300);
}

不幸的是,这不起作用。主页由“Sahifa Home Builder”制作,所以它不是简单的博客文章或静态页面。有人吗?没有小费吗?
if ( is_home() || is_front_page() ) {
    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);
  }