首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >为什么该网站只在类别页面中显示“网站正经历技术困难”错误?

为什么该网站只在类别页面中显示“网站正经历技术困难”错误?
EN

Stack Overflow用户
提问于 2019-07-16 07:41:36
回答 1查看 338关注 0票数 0

每当我从发布的任何页面或帖子中单击某个类别,进入该类别档案时,它都会给我这个错误,而不是显示该类别的帖子。它只显示带有错误的站点标头。大多数其他页面都能正常工作。

我不知道这是否是造成问题的原因,但由于该网站有一个‘只成员’的内容插件,其中显示一些帖子,只有在网站的成员签名。此外,Yoast插件还可以选择将post的类别作为“主要”类别,并且由于类别是按字母顺序排序的,例如,如果我们选择cat-1和cat-2,并将cat-2作为主要类别,则如果cat-1在cat-2之前按字母顺序排序,它就会在网站上显示cat-1。成员和技术,即使我们选择技术为主要,成员将显示在现场,在原来的面包屑前。)。

我想要做的是隐藏实际的面包屑,并通过遵循他们的FAQ中的指示来显示Yoast面包屑。它涉及到添加一个小代码,我在实际的面包屑代码之前添加了它,并注释了实际的面包屑代码(它只是一个被调用的函数名,但无论如何它是禁用的)。然后,我从Yoast的设置面板(添加了关于添加面包屑的小代码)启用了面包屑选项。

它运行良好,首先显示主选中的类别,但是当我们输入类别存档页面时(通过单击这个页面从面包屑或菜单下拉菜单中单击它,没有区别),它就会显示这个错误。我禁用了一些插件,也使用了Health插件,并对一些插件进行了故障排除,但没有取得积极的结果。

我启用了调试模式以查看错误是什么,这就是它所显示的:

  • 在标题上方:

注意: is_author被错误地调用。在运行查询之前,条件查询标记无法工作。在此之前,他们总是返回错误。有关详细信息,请参阅WordPress中的调试。(此消息是在3.1.0版中添加的。)在./ 弃用:与其类同名的方法不会是将来版本的PHP中的构造函数;在第61行的.../------/wp-content/plugins/amp-story/vafpress/includes/wpalchemy/MetaBox.php中,WPAlchemy_MetaBox有一个不推荐的构造函数。 注意:第50行.../------/wp-content/plugins/amp-story/amp-story.php中的未定义索引: amp

  • 在错误文本的上方:

可恢复的致命错误:在第2696行的.../------/wp-content/themes/15zine/library/core.php中,无法将类WP_Error的对象转换为字符串

我实际上关闭了AMP插件,但没有看到任何变化。这可能是另一个问题,但我怀疑Yoast插件改变了类别结构的一些东西,但不完全确定。

代码语言:javascript
复制
// Actual breadcrumb function call
<?php cb_breadcrumbs(); ?>
// Yoast breadcrumb code
<?php
if ( function_exists('yoast_breadcrumb') ) {
  yoast_breadcrumb( '<p id="breadcrumbs">','</p>' );
}
?>
代码语言:javascript
复制
// About the breadcrumbs function in core.php file
代码语言:javascript
复制
if ( ! function_exists( 'cb_breadcrumbs' ) ) {

function cb_breadcrumbs() {

    echo cb_get_breadcrumbs();
}

}如果(!function_exists( 'cb_get_breadcrumbs‘){

代码语言:javascript
复制
function cb_get_breadcrumbs() {

    if ( ot_get_option('cb_breadcrumbs', 'on') == 'off' ) {
        return;
    }

    $cb_breadcrumb = NULL;
    $cb_post_type = get_post_type();
    $cb_cpt = cb_get_custom_post_types();

    if ( is_page() ) {

        global $post;
        if ( $post->post_parent == 0 ) {
            return;
        }
    }


    $cb_breadcrumb = '<div class="cb-breadcrumbs">';
    $cb_icon = '<i class="fa fa-angle-right"></i>';
    $cb_breadcrumb .= '<a href="' . esc_url( home_url() ) . '">' . __("Home", "cubell").'</a>' . $cb_icon;

    if ( is_date() ) {

        if ( is_day() ) {
            $cb_breadcrumb_output = get_the_date( 'F j, Y' );
        } elseif ( is_month() ) {
            $cb_breadcrumb_output = single_month_title( ' ', false );
        } elseif ( is_year() ) {
            $cb_breadcrumb_output = get_query_var( 'year' );
        }

         $cb_breadcrumb .=  '<div itemscope itemtype="http://data-vocabulary.org/Breadcrumb">' . $cb_breadcrumb_output . '</div>';
    } elseif ( is_tag() ) {
        $cb_tag_id = get_query_var('tag_id');

        $cb_breadcrumb .= '<div itemscope itemtype="http://data-vocabulary.org/Breadcrumb"><a href="' . get_tag_link($cb_tag_id) . '" title="' . esc_attr( sprintf( __( "View all posts in %s", "cubell" ), single_tag_title( '', FALSE ) ) ) . '" itemprop="url"><span itemprop="title">' . single_tag_title( '', FALSE ) . '</span></a></div>';

    } elseif ( is_category() ) {

        $cb_cat_id = get_query_var('cat');
        $cb_current_category = get_category( $cb_cat_id );

        if ( $cb_current_category->category_parent == '1' ) {

            $cb_breadcrumb .= '<div itemscope itemtype="http://data-vocabulary.org/Breadcrumb"><a href="' . get_category_link( $cb_current_category->term_id ) . '" title="' . esc_attr( sprintf( __( "View all posts in %s", "cubell" ), $cb_current_category->name ) ) . '" itemprop="url"><span itemprop="title">' . $cb_current_category->name . '</span></a></div>';

        }

        // Line 2696 starts from here  
        // else 
        // {
        //
        //      $cb_breadcrumb .=  '<div itemscope itemtype="http://data-vocabulary.org/Breadcrumb"><a href="' . get_category_link( $cb_current_category->category_parent ) . '" title="' . esc_attr( sprintf( __( "View all posts in %s", "cubell" ), get_the_category_by_ID( $cb_current_category->category_parent ) ) ) . '"><span itemprop="title">' . get_the_category_by_ID( $cb_current_category->category_parent ) . '</span></a></div>' . $cb_icon;
        //      $cb_breadcrumb .= '<div itemprop="child" itemscope itemtype="http://data-vocabulary.org/Breadcrumb"><a href="' . get_category_link( $cb_current_category->term_id ) . '" title="' . esc_attr( sprintf( __( "View all posts in %s", "cubell" ), $cb_current_category->name ) ) . '" itemprop="url"><span itemprop="title">' . $cb_current_category->name . '</span></a></div>';
        //
        //  }

    } elseif ( function_exists('buddypress') && ( is_buddypress() ) )  {
        global $bp;
        $cb_bp_output = NULL;
        $cb_bp_current_component = bp_current_component();
        $cb_bp_current_action = bp_current_action();

        if ( ( $cb_bp_current_action != 'my-groups' ) && ( $cb_bp_current_component == 'groups' ) ) {

            $cb_bp_group = $bp->groups->current_group;

            if ( ! is_numeric( $cb_bp_group ) ) {
                $cb_bp_group_id = $cb_bp_group->id;
                $cb_bp_group_name = $cb_bp_group->name;
                $cb_bp_group_link = bp_get_group_permalink($cb_bp_group);
                $cb_bp_output = '<div itemscope itemtype="http://data-vocabulary.org/Breadcrumb"><a href="' . trailingslashit( bp_get_root_domain() . '/' . bp_get_groups_root_slug() ) . '" itemprop="url"><span itemprop="title">' . __('Groups', 'cubell') . '</span></a></div>' . $cb_icon . $cb_bp_group_name;
            } else {
                $cb_bp_output =  __('Groups', 'cubell');
            }

            $cb_breadcrumb .=  $cb_bp_output;
        }

        if ( ( $cb_bp_current_component == 'activity' ) || ( $cb_bp_current_action == 'my-groups' ) || ( $cb_bp_current_action == 'public' ) || ( $cb_bp_current_component == 'settings' ) || ( $cb_bp_current_component == 'forums' ) || ( $cb_bp_current_component == 'friends' ) ) {

            if ( isset( $bp->activity->current_id ) ) {
                $cb_bp_activity = $bp->activity->current_id;
            } else {
                $cb_bp_activity = NULL;
            }

            $cb_activity_title = get_the_title();
            $cb_bp_activity_link = bp_get_members_directory_permalink();
            $cb_bp_output .=  '<div itemscope itemtype="http://data-vocabulary.org/Breadcrumb"><a href="' . esc_url( $cb_bp_activity_link ) . '" itemprop="url"><span itemprop="title">' . __('Members', 'cubell') . '</span></a></div>' . $cb_icon . $cb_activity_title;

            if ( $cb_bp_activity != NULL ) {

                $cb_bp_output .=  __('Members', 'cubell');
            }

            $cb_breadcrumb .=  $cb_bp_output;
        }

        if ( $cb_bp_current_component == 'messages' ) {

            $cb_breadcrumb .=  __('Messages', 'cubell');
        }

        if ( $cb_bp_current_component == 'register' ) {

            $cb_breadcrumb .=  __('Register', 'cubell');
        }

        if ( bp_is_directory() ) {
            $cb_breadcrumb = '<div>';
        }

    } elseif ( ( in_array( $cb_post_type, $cb_cpt ) == true ) || ( $cb_post_type == 'post' ) ) {

        $cb_categories =  get_the_category();

        if ( ! empty ( $cb_categories ) ) {

            if ( $cb_categories[0]->category_parent == '0' ) {

                $cb_breadcrumb .=  '<div itemscope itemtype="http://data-vocabulary.org/Breadcrumb"><a href="' . get_category_link($cb_categories[0]->term_id) . '" title="' . esc_attr( sprintf( __( "View all posts in %s", "cubell" ), $cb_categories[0]->name ) ) . '" itemprop="url"><span itemprop="title">' . $cb_categories[0]->name.'</span></a></div>';

            } else {

                $cb_breadcrumb_output = '<a href="' . get_category_link($cb_categories[0]->category_parent) . '" title="' . esc_attr( sprintf( __( "View all posts in %s", "cubell" ), get_the_category_by_ID($cb_categories[0]->category_parent) ) ) . '" itemprop="url"><span itemprop="title">' . get_the_category_by_ID($cb_categories[0]->category_parent) . '</span></a>' . $cb_icon;

                $cb_breadcrumb_output .= '<a href="' . get_category_link($cb_categories[0]->term_id) . '" title="' . esc_attr( sprintf( __( "View all posts in %s", "cubell" ), $cb_categories[0]->name ) ) . '" itemprop="url"><span itemprop="title">' . $cb_categories[0]->name . '</span></a>';

                $cb_current_cat = get_category($cb_categories[0]->category_parent);

                if ( $cb_current_cat->category_parent != '0' ) {

                    $cb_breadcrumb_output = '<a href="' . get_category_link($cb_current_cat->category_parent) . '" title="' . esc_attr( sprintf( __( "View all posts in %s", "cubell" ), get_the_category_by_ID($cb_current_cat->category_parent) ) ) . '" itemprop="url"><span itemprop="title">' . get_the_category_by_ID($cb_current_cat->category_parent) . '</span></a>' . $cb_icon . $cb_breadcrumb_output;

                    $cb_current_cat = get_category( $cb_current_cat->category_parent );

                    if ( $cb_current_cat->category_parent != '0' ) {

                        $cb_breadcrumb_output = '<a href="' . get_category_link($cb_current_cat->category_parent) . '" title="' . esc_attr( sprintf( __( "View all posts in %s", "cubell" ), get_the_category_by_ID($cb_current_cat->category_parent) ) ) . '" itemprop="url"><span itemprop="title">' . get_the_category_by_ID($cb_current_cat->category_parent) . '</span></a>' . $cb_icon . $cb_breadcrumb_output;

                        $cb_current_cat = get_category( $cb_current_cat->category_parent );

                        if ( $cb_current_cat->category_parent != '0' ) {

                            $cb_breadcrumb_output = '<a href="' . get_category_link($cb_current_cat->category_parent) . '" title="' . esc_attr( sprintf( __( "View all posts in %s", "cubell" ), get_the_category_by_ID($cb_current_cat->category_parent) ) ) . '" itemprop="url"><span itemprop="title">' . get_the_category_by_ID($cb_current_cat->category_parent) . '</span></a>' . $cb_icon . $cb_breadcrumb_output;
                        }
                    }

                }

                $cb_breadcrumb .=  '<div itemscope itemtype="http://data-vocabulary.org/Breadcrumb">' . $cb_breadcrumb_output . '</div>';

            }
        }

    } elseif ( is_page() ) {
        $cb_parent_page = get_post( $post->post_parent );

        $cb_parent_page_title = $cb_parent_page->post_title;
        $cb_breadcrumb .=  '<div itemscope itemtype="http://data-vocabulary.org/Breadcrumb"><a href="' . get_permalink( $cb_parent_page->ID ) . '"><span itemprop="title">' . $cb_parent_page_title . '</span></a></div>';
    }


    $cb_breadcrumb .= apply_filters( 'cb_breadcrumbs_output', '' );
    $cb_breadcrumb .= '</div>';


    return $cb_breadcrumb ;
}

}

正如我已经解释并提供了问题的背景,我希望看到正确的面包屑(我看到了),并使分类页工作,但相反,我只看到以中心为中心的网站的标题和错误“网站正在经历技术困难”。在它下面。据我所查,大多数其他页面运行良好,只有类别页有此问题。甚至管理面板也在正常工作。

EN

回答 1

Stack Overflow用户

发布于 2019-07-16 11:54:24

希望这能有所帮助

代码语言:javascript
复制
if ( $cb_current_category->category_parent == '1' ) {

把它改成

代码语言:javascript
复制
if ( $cb_current_category->category_parent == '0' ) {

从第2696行的注释中删除comment。其中一个附加内容不是"string",而是一个WP_Error对象。

这也可能是Siteurl问题。WordPress数据库中的Siteurl选项值可能不包含有效条目

运行以下查询以验证该值确实不正确

代码语言:javascript
复制
SELECT * FROM `wp_options` WHERE option_name = 'siteurl';

您可能会发现一个包含WP_Error对象的序列化数组。通过使用域的URL设置选项值来更正该选项值。

代码语言:javascript
复制
UPDATE wp_options SET option_value = '[YOUR URL]' WHERE option_name = 'siteurl';

可能是恶意软件感染了你的安装。一定要在您的服务器上运行扫描。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/57052335

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档