0

I am an amateur and I am trying to edit a theme that I have bought and I am not able to display the category name and link. Does anyone to resolve this problem.

<div class="item-info">';
                        if($show_aut!='0'){
                            $author = get_author_posts_url( get_the_author_meta( 'ID' ) );
                          $html .= '<span  class="item-author"><a href="'.$author.'" title="'.get_the_author().'">'.get_the_author().'</a></span>';}

                           //DISPLAY CATEGORY LINK AND NAME
                         if($show_sub_aut!='0'){
                            $subaut = get_the_category();
                          $html .= '<span  class="item-sub-aut"><a href="'.$subaut.'" title="'.get_category_link().'">'.get_category_link().'</a></span>';}


                        if($show_date!='0'){  
                          $html .= '<span class="item-date">'.get_the_time(get_option('date_format')).'</span>';}
                          $html .= '<div class="item-meta no-bg">';
                          if($show_view!='0' ){
                          $html .= tm_html_video_meta('view',false,false);}
                          if($show_com!='0' ){
                          $html .= tm_html_video_meta('comment',false,false);}
                          if($show_like!='0'){
                          $html .= tm_html_video_meta('like',false,false);}
                          $html .= '</div>
                      </div>';
2
Contributors
1
Reply
10
Views
1 Year
Discussion Span
Last Post by hericles
0

The wordpress docs for get_the_category says:
"Note: This function only returns results from the default “category” taxonomy. For custom taxonomies use get_the_terms()."

So you might want to try that as an alternative. Otherwise, after the call to get_the_category, add:
var_dump($subaut); die();
This will kill the page generation (die) but dump out the result of the method call onto the screen. You can then check that it is something rather than nothing.
The result of get_the_category is an array rather than an actual category name so
<a href="'.$subaut.'"
won't work anyway as $subaut isn't a string of text that can be placed into an anchor link. It might be something like $subaut->name instead. Again, looking at the dumped result should make it apparent what part of $subaut you actually need.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.