Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/joomla/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 在wordpress博客上全局隐藏(而不是删除)类别名称_Php_Wordpress_Categories - Fatal编程技术网

Php 在wordpress博客上全局隐藏(而不是删除)类别名称

Php 在wordpress博客上全局隐藏(而不是删除)类别名称,php,wordpress,categories,Php,Wordpress,Categories,我试图隐藏一个特定的类别名称,例如,在我的整个wordpress博客中称为Featured。请注意,我不想排除属于该特定类别的帖子,我只想阻止实际类别名称显示出来。无论如何,它应该是不可见的 我在functions.php中找到了一个代码片段,实际上它完全符合我的要求,但它只是在post-meta部分隐藏了类别名称,对仍然显示类别名称的第三方插件没有任何影响。你能帮我把这个应用到一个特定的插件上吗 function.php中隐藏类别名称的代码: function the_category_fil

我试图隐藏一个特定的类别名称,例如,在我的整个wordpress博客中称为Featured。请注意,我不想排除属于该特定类别的帖子,我只想阻止实际类别名称显示出来。无论如何,它应该是不可见的

我在functions.php中找到了一个代码片段,实际上它完全符合我的要求,但它只是在post-meta部分隐藏了类别名称,对仍然显示类别名称的第三方插件没有任何影响。你能帮我把这个应用到一个特定的插件上吗

function.php中隐藏类别名称的代码:

function the_category_filter($thelist,$separator=' ') {
if(!defined('WP_ADMIN')) {

    $exclude = array('featured');
    $cats = explode($separator,$thelist);
    $newlist = array();
    foreach($cats as $cat) {
        $catname = trim(strip_tags($cat));
        if(!in_array($catname,$exclude))
            $newlist[] = $cat;
    }
    return implode($separator,$newlist);
} else
    return $thelist;
}
add_filter('the_category','the_category_filter',10,2);
Plungin的函数如下所示:

private function generate_post_categories( $post ) {

    // Setting up category list string.
    $post_cat_string = '';

    // Setting up category list.
    $post_cat_list = '';

    // Fetching post category prefix  with WPML support.
    $post_category_prefix = ($this->icl_t) ? icl_t('ORP Post Category Prefix', 'post-category-prefix–' . $this->widget_id, $this->widget_args['post_category_prefix'] ) : $this->widget_args['post_category_prefix'];

    // Checking for post category PREFIX.
    if ( !empty( $this->widget_args['post_category_prefix'] ) ) {

        // Building post category PREFIX HTML.
        $post_cat_string .= esc_html( $post_category_prefix );
    }

    // Retrieving categories array.
    $orp_categories = get_the_category( $post->ID );

    // Checking if "post category link" option is on.
    if ( 'yes' == $this->widget_args['post_category_link'] ) {

        // Looping through categories array.
        foreach( $orp_categories as $orp_cat ) {

            // Fetching the current category link.
            $orp_category_link = get_category_link( $orp_cat->cat_ID );

            // Building HTML link atts.
            $linkatts = array(
                'href'  => $orp_category_link,
                'title' => $orp_cat->cat_name
            );

            // Building category link HTML.
            $post_cat_list .= $this->orp_create_tag( 'a', $orp_cat->cat_name, $linkatts ) . esc_html( $this->widget_args['post_category_separator'] );
        }

    } else {

        // Looping through categories array.
        foreach( $orp_categories as $orp_cat ) {

            // Filling categories list.
            $post_cat_list .= $orp_cat->cat_name . esc_html( $this->widget_args['post_category_separator'] );
        }
    }

    // Right trimming the last category separator on the category list.
    $post_cat_string .= rtrim( $post_cat_list, esc_html( $this->widget_args['post_category_separator'] ) );

    // Returning the post category HTML.
    return $this->orp_create_tag( 'div', $post_cat_string, array( 'class' => 'orp-post-category' ) );

您能否尝试更改此部分:

// Looping through categories array.
foreach( $orp_categories as $orp_cat ) {
致:


如果类别名称等于Featured,则应跳过循环

您必须查看类别名称在插件中的显示方式。这是类别在插件中的显示方式:$new=$This->generate\u post\u categories$recent\u posts->post$orp_内容=$new;generate_post_categories是插件函数之一,您应该查看它。找到了该函数,但我不知道要查找什么,以及在上面的代码中必须替换哪个变量。这就是我要找的电话线吗$linkatts=array'href'=>$orp\u category\u链接,'title'=>$orp\u cat->cat\u名称;这里是-它从category对象获取category名称,因此它不会通过_category过滤器。我建议您编辑您的问题,从generate_post_categories和调用位置添加代码,以便查看我们可以在哪里添加条件。先生,这样做了。我非常感谢你的帮助,如果可以的话,我会投赞成票;快乐它修复了它;如果它解决了您的问题,您可以通过单击左侧的绿色复选框接受答案:DIED so。再次感谢你;
// Looping through categories array.
foreach( $orp_categories as $orp_cat ) {
  if($orp_cat->cat_name == 'Featured') {
    continue;
  }