Wordpress 限制自定义文章类型中的摘录长度并删除括号

Wordpress 限制自定义文章类型中的摘录长度并删除括号,wordpress,custom-post-type,Wordpress,Custom Post Type,我试图将我的自定义帖子的摘录长度限制在100个字符以内,并删除句子末尾的括号。我已经尝试了堆栈溢出上列出的各种解决方案,但至今没有任何效果 我有4个自定义帖子类型:排毒、食谱、运动、生活方式 请使用以下代码删除括号 function remove_excerpt_more( $more ) { return ''; } add_filter('excerpt_more', 'remove_excerpt_more'); 并使用下面的代码限制摘录的长度 function custom_e

我试图将我的自定义帖子的摘录长度限制在100个字符以内,并删除句子末尾的括号。我已经尝试了堆栈溢出上列出的各种解决方案,但至今没有任何效果

我有4个自定义帖子类型:排毒、食谱、运动、生活方式


请使用以下代码删除括号

function remove_excerpt_more( $more ) {
    return '';
}
add_filter('excerpt_more', 'remove_excerpt_more');
并使用下面的代码限制摘录的长度

function custom_excerpt_length( $length ) {
global $post;
if ($post->post_type == 'post')
  return 25;
else if ($post->post_type == 'custom_post_type')
  return 15;
else
  return 25;
}
   return 20;
}
add_filter( 'excerpt_length', 'custom_excerpt_length', 999 );

请使用以下代码删除括号

function remove_excerpt_more( $more ) {
    return '';
}
add_filter('excerpt_more', 'remove_excerpt_more');
并使用下面的代码限制摘录的长度

function custom_excerpt_length( $length ) {
global $post;
if ($post->post_type == 'post')
  return 25;
else if ($post->post_type == 'custom_post_type')
  return 15;
else
  return 25;
}
   return 20;
}
add_filter( 'excerpt_length', 'custom_excerpt_length', 999 );

请添加您的代码,然后我们才能检查问题您指的是什么代码?请添加您的代码,然后我们才能检查问题您指的是什么代码?谢谢您的建议。不幸的是,这两个问题都没有解决。这是我以前尝试过的代码,它似乎对博客帖子没有任何影响。谢谢你的建议。不幸的是,这两个问题都没有解决。这是我以前尝试过的代码,它似乎对博客帖子没有任何影响。