I want to add the title of a custom taxonomy term to an archive page. I created 2 demo sites and I tried to see how it is done on the them:
hidden link
hidden link
but apart from the WordPress Search and Output, I don't see how the title is inserted. And in the photographers' case, the archive is also used as a custom post archive with a different title in that case.
I follow the tutorial
https://toolset.com/course-lesson/creating-a-custom-archive-page/
but I didn't find how to insert the title above the archive.
I'm attaching the backend of the photographers' archive.
Thank you!
Hi,
Thank you for contacting us and I'd be happy to assist.
When a WordPress Archive is customized through Toolset, it only affects the archive's content area and not the header and footer sections around it.
In the demo website links that you shared, the archive titles are also being added by the active themes, Blocksy and Astra, respectively.
To include the archive's title within the content area controlled through Toolset, you can register a custom shortcode, for example:
add_shortcode( 'custom_archive_title', 'custom_archive_title_func');
function custom_archive_title_func($atts)
{
$a = shortcode_atts( array(
'before' => '',
'after' => ''
), $atts );
$output = get_the_archive_title();
return $a['before'].$output.$a['after'];
}
The above code snippet can be included through either Toolset's custom code feature ( ref: https://toolset.com/documentation/adding-custom-code/using-toolset-to-add-custom-code/ ) or through the active theme's "functions.php" file.
After that, you can use this shortcode in your Toolset archive, like this:
[custom_archive_title before='<h1>' after='</h1>']
I hope this helps and please let me know if you need any further assistance around this.
regards,
Waqar
Hi,
How did you add the archive title using the Astra theme? Do you mean that you added in the PHP templates of the theme or the child theme?
Thanks for writing back.
> How did you add the archive title using the Astra theme?
> Do you mean that you added in the PHP templates of the theme or the child theme?
- No extra steps are needed to show the archive title, because the Astra theme shows it by default.
My issue is resolved now. Thank you!