-
AuthorPosts
-
February 14, 2015 at 7:14 am #396111
Hi there,
I am using the Magazine Content Element to list blog posts – It displays blog title with the date above but I would also like to display the post category(s) after the date. This is how all the other listings appear eg on single post page and the Blog Post Content Element. For consistency shouldn’t the magazine list also display the category or tag chosen? This is crucial information to the user for identifying content relevance.
Can you help?
I have seen how to add excerpt and Read More to magazine element but not how to add category to the meta list.
Thanks in advance.
February 14, 2015 at 8:46 am #396118I do understand now how the magazine layout is designed to work – using the tabs for sorting categories – and therefore there would be no need to list category above the post title. However I was going to use the magazine layout without tabs because I have 20 – 30 categories and so it would be too many to use the tabs and list all the options for sorting.
It would therefore still be useful to be able to have the category listed after the date above the post title to identify the information without having to list all categories as tabs.
Hope that makes sense?
February 16, 2015 at 8:23 am #396543Hey!
Best regards,
JosueFebruary 16, 2015 at 12:56 pm #396662Hi Josue,
Thanks for your help but I don’t want to add a specific piece of text (eg MEMBERS ONLY) – I would like to automatically display the relevant category of the listed post.
So…
Post title
Date / Category
underlinefor each post in the magazine list
February 16, 2015 at 4:31 pm #396788Hi!
OK, ignore the CSS part, just make that part of the magazine.php code like this:
$magazine_category = get_the_category($entry->ID); $output .= "<div class='av-magazine-content-wrap'>"; $output .= "<header class='entry-content-header'>"; $output .= "<time class='av-magazine-time updated' {$markupTime}>".$time."</time>"; $output .= $separator.$author_output." / ".$magazine_category[0]->name; $output .= "<{$titleTag} class='av-magazine-title entry-title' {$markupTitle}>{$title}</{$titleTag}>"; $output .= "</header>"; if($excerpt)$output .= "<div class='av-magazine-content entry-content' {$markupContent}>{$excerpt}</div>"; $output .= "</div>"; $output .= "<footer class='entry-footer'></footer>"; $output .= "</article>";
Regards,
JosueMarch 22, 2019 at 11:08 pm #1082031What’s the best way to make the Category as a link to its archive page?
And will this code loop and display multiple categories?
- This reply was modified 5 years, 8 months ago by dhfairbairn.
March 28, 2019 at 4:32 am #1083907Hi,
The modification above will only display the first category of the post. If you want it to link to the category archive page, use the available snippet from the docs.
// https://developer.wordpress.org/reference/functions/get_the_category/#user-contributed-notes
Best regards,
Ismael -
AuthorPosts
- You must be logged in to reply to this topic.