Displaying Category Name (close, but not correct yet)
-
Hi Bill,
So thankful for this plugin, but there’s one additional thing I need it to do that I can’t figure out. I need the shortcode to output the category of the post it displays (linked to the category archive), below the title. I’ve been trying to edit the code you provided to add the authorship link, and I seem to be on the right track but clearly not correct either. Here is the link I’m working with – https://chaarg.mattdotcom.com/blog/ – and here is the code I currently ahve in my functions.php file:
add_filter( 'display_posts_shortcode_output', 'be_display_posts_facebook', 10, 7 ); function be_display_posts_facebook( $output, $atts, $image, $title, $category, $date, $excerpt, $inner_wrapper ) { // Here's the CATEGORY $category = get_the_category(); if($category[0]){ echo '<a href="'.get_category_link($category[0]->term_id ).'">'.$category[0]->cat_name.'</a>'; } // Now let's rebuild the output and add the $author to it $output = '<' . $wrapper . ' class="listing-item">' . $image . $title . $category . $date . $author . $excerpt . '</' . $wrapper . '>'; // Finally we'll return the modified output return $output; }
Please help!!
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Displaying Category Name (close, but not correct yet)’ is closed to new replies.