I’m trying to customize the archive template for tags. I use tags to associate articles and posts with different subjects. However, I have a page category called “encyclopedia” which gives a summary explanation of the subject. I have the encyclopedia subpages available through a menu.
What I want is to display the encyclopedia page when a tag is clicked, before the post loop with all the relevant pages.
Essentially I want to modify the archive template to check if an encyclopedia page of the same name exists, “/tag/subject101/” -> “/encyclopedia/subject101/”. If the page exists, display that content, and keep the post loop after. If the page does not exist, proceed with the loop as usual.
I’ve looked a the forums for days and still haven’t found any examples. I’d appreciate any pointers!
Hi Joshua
Thanks for reaching out.
I wish we could dive into this here. To remain viable our free support scope is limited to basic usage and troubleshooting questions.
You’ll need to use a child theme. Here is a useful page on WordPress conditionals: https://codex.wordpress.org/Conditional_Tags#A_Tag_Page. You’d most likely add your conditional to archive.php copied from the parent to the child.
For more in-depth help, you might consider a SiteOrigin Premium license. Premium allows us to offer more in-depth advice on customization tasks of this nature. You could also consider codeable.io if you ever wanted to hire a developer to assist.
I figured it out! Added the following code to archive.php.
Awesome! Really glad to hear you’ve been making progress. Thanks for sharing your work here :)