Reputation: 41
Whenever I click on a category from any of the pages or posts which are posted, to go to that category archives, it gives me this error instead of showing the posts of that category. It only shows the site header with the error. Most other pages working fine.
I'm not sure if that's what caused the problem, but as the site has a 'Members only' content plugin which shows some posts to only the signed in members of the site. Also, Yoast plugin has an option of making a category of a post as a 'Primary' category, and as the categories are sorted in alphabetical order, if for example, we chose cat-1 and cat-2 and made the cat-2 a Primary category, it would show cat-1 on the website if cat-1 is alphabetically sorted before cat-2 (for ex. Member and Technology, if even we chose Technology as Primary, Member will be shown on site, on original breadcrumb for ex.).
What I tried to do is to hide the actual breadcrumb and show the Yoast breadcrumb instead by following their instructions from their FAQ. It involves adding a small code, I added it before the actual breadcrumb code and commented the actual breadcrumb's code (which is only just a function name that is called, but it disabled anyway). Then I enabled the breadcrumb option from Yoast's settings panel (Added small code about adding the breadcrumb).
It was working fine and shows the primary checked category first, but then when we enter the category archive page (by clicking on it from breadcrumb or menu dropdown, no difference), it shows that error. I disabled a few plugins and also used the Health Check plugin and did some troubleshooting with it with some plugins disabled, but no positive results.
I enabled debug mode to see what is the error, and this is what it shows:
Notice: is_author was called incorrectly. Conditional query tags do not work before the query is run. Before then, they always return false. Please see Debugging in WordPress for more information. (This message was added in version 3.1.0.) in .../------/wp-includes/functions.php on line 4773
Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; WPAlchemy_MetaBox has a deprecated constructor in .../------/wp-content/plugins/amp-story/vafpress/includes/wpalchemy/MetaBox.php on line 61
Notice: Undefined index: amp in .../------/wp-content/plugins/amp-story/amp-story.php on line 50
Recoverable fatal error: Object of class WP_Error could not be converted to string in .../------/wp-content/themes/15zine/library/core.php on line 2696
I actually deactivated the AMP plugins but no change was seen. It could be of another issue but I'm suspecting that the Yoast plugin changed some things of the category structure, but not fully sure though.
// Actual breadcrumb function call
<?php cb_breadcrumbs(); ?>
// Yoast breadcrumb code
<?php
if ( function_exists('yoast_breadcrumb') ) {
yoast_breadcrumb( '<p id="breadcrumbs">','</p>' );
}
?>
// About the breadcrumbs function in core.php file
if ( ! function_exists( 'cb_breadcrumbs' ) ) {
function cb_breadcrumbs() {
echo cb_get_breadcrumbs();
}
} if ( ! function_exists( 'cb_get_breadcrumbs' ) ) {
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 ;
}
}
As I explained and provided the background of the issue already, I expected to see the correct breadcrumb (which I saw) and also to make the categories pages working, but instead, I only see the header of the site off-centered and the error "The site is experiencing technical difficulties." under it. Most other pages are working fine as far as I checked, only the category pages have this issue. Even the admin panel is working normally.
Upvotes: 0
Views: 378
Reputation: 197
Hope this helps
if ( $cb_current_category->category_parent == '1' ) {
Change it to
if ( $cb_current_category->category_parent == '0' ) {
remove the else from the comment from line 2696. one of those things being appended is not a "string", but actually a WP_Error object.
It might Siteurl problem as well. the Siteurl option value in your WordPress database may not contain a valid entry
Run the following query to verify that the value is indeed incorrect
SELECT * FROM `wp_options` WHERE option_name = 'siteurl';
You will likely find a serialized array containing a WP_Error object. Correct the option value by setting it with your domain’s URL.
UPDATE wp_options SET option_value = '[YOUR URL]' WHERE option_name = 'siteurl';
there might be malware has infected your installation. Be sure to run a scan on your server.
Upvotes: 0