Archived topic
Hook to fetch and show category.
5 replies · Started by Arnab Mohapatra on May 16, 2020
Hi,
I wanted to fetch Category and show it above the title.
Example- https://d.pr/i/cVCeAL However, this is being added as {{post_terms.category}} shortcode and header elements.
But the shortcode doesn't work when placed in a hooks element. How do I fetch the category details in hooks?
I want to add category fields here https://d.pr/i/sYkZG6 .
Can you help me ?
Thanks
Arnab
Hi there,
Try this solution here:
https://generatepress.com/forums/topic/display-post-categories-above-title/#post-645410
Adding PHP: https://docs.generatepress.com/article/adding-php/
Let me know if this helps :)
Hi Leo,
It helped. 2 more thing.
1- add same margin as author filed below, explanation- https://d.pr/i/JRsizR
2- align it to centre in mobile https://d.pr/i/MguqrB
Page URL- https://d.pr/qwMgxd
Thanks
Hi there,
add this CSS:
.entry-header .hero-category.cat-links {
display: block;
margin-bottom: 1em;
}
Thanks, David,
It worked.
Glad we could be of help