Archived topic
Use Category/Tag descriptions as dynamic Content?
5 replies · Started by Jabien on March 24, 2022
Hi,
Is it possible to use Category/Tag descriptions as dynamic Content? For instance, if I want to use a category's description as the page title, can I do that?
Thanks in advance!
Cheers,
Jabien
Hi Jabien,
I don't think the dynamic block can achieve this, the category/tag descriptions are usually be called on archive pages.
And usually pages don't have category assigned to them.
However you can try something like this to call category description:
function show_category_description() {
$taxonomy ='category';
echo term_description( get_the_terms($post->ID , $taxonomy)[0], $taxonomy );
}
I was using the word "page" but I think a more accurate description would be that I want the Archive Pages to pull their title from the category description.
Would that function work for what I am trying to do? If so, where exactly do I put it?
If you are talking about archive, then there's no custom function needed.
You can use adynamic contentblock, choose term description as the type:
https://www.screencast.com/t/PVrxaos4zqS
Choose post category archive as location in this case.
Okay great, this gets me halfway there. Now it has the description where I need it but I can't format the typography of the dynamic content to look like a title. This is basically the last thing I need to move my site away from Elementor (I think). Any way to do that?
You can wrap a containerblock outside thedynamic content, the style of the container block will pass on to the dynamic content.