Friday, November 11, 2022
HomeWordPress Developmentclasses - get_the_category:An error occurred once I tried to getthe ID of...

classes – get_the_category:An error occurred once I tried to getthe ID of the class


An error occurred once I tried to get the ID of the class.The obtained id is the id of its subcategory.Beneath is the code:

else if (is_category()){
    $title = single_cat_title( '', false ).$weiba;
    $description = htmlentities(strip_tags(trim(category_description())), ENT_QUOTES, 'UTF-8');
    $category_info = get_the_category();
    $category_id = $category_info[0]->cat_ID;
    $key phrases = get_option('_category_keywords'.$category_id);
    $key phrases = $key phrases.$category_id;
  }

I printed the obtained array as follows:

Array
(
    [0] => WP_Term Object
        (
            [term_id] => 3
            [name] => 行业资讯
            [slug] => hynews
            [term_group] => 0
            [term_taxonomy_id] => 3
            [taxonomy] => class
            [description] => 关于厂房夹心板,畜牧用夹心板,净化板,冷库板夹心板的最新资讯。
            [parent] => 1
            [count] => 47
            [filter] => uncooked
            [cat_ID] => 3
            [category_count] => 47
            [category_description] => 关于厂房夹心板,畜牧用夹心板,净化板,冷库板夹心板的最新资讯。
            [cat_name] => 行业资讯
            [category_nicename] => hynews
            [category_parent] => 1
        )

 

Can anybody inform me methods to clear up it, thanks rather a lot!//有没有大佬可以告诉我怎么解决的,非常感谢!

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments