Archived topic
How to Add HTML in Child Theme
6 replies · Started by Andres on August 15, 2020
Hello,
Could you please help me add HTML in GP Pro?
I see there are 2 options: 1. Elements > Hooks, but this requires adding a function to enable PHP execution in Hooks if it's disabled in wp-config.php, which permits PHP execution in Hooks, and 2. Adding the HTML directly to the child theme?
If I don't want to allow PHP execution at all in Elements/Hooks, then Option 2 is the only viable one, right? If that's the case, could you please explain how to add HTML to a child theme and use the hook: generate_after_archive_description so the filter appears just above the posts list?
The HTML below is to add filtering functionality to a custom category php template that's using WPSP for the posts feed. Below is the HTML to add, for reference.
<span class="scf_tags_group" style="color: #3a3a3a;">
<a class="scf_tag_button preselected" data-val="All" style="color: #000000;">ALL</a>
<a class="scf_tag_button" data-val="Engagements" style="color: #000000;">ENGAGEMENTS</a>
<a class="scf_tag_button" data-val="Weddings" style="color: #000000;">WEDDINGS</a>
</span>
Thank you, and have a good day!
Hi there,
try this:
add_action( 'generate_after_archive_description', function() {
echo '<span class="scf_tags_group" style="color: #3a3a3a;">
<a class="scf_tag_button preselected" data-val="All" style="color: #000000;">ALL</a>
<a class="scf_tag_button" data-val="Engagements" style="color: #000000;">ENGAGEMENTS</a>
<a class="scf_tag_button" data-val="Weddings" style="color: #000000;">WEDDINGS</a>
</span>';
});
Hello David,
Thank you for the help.
One question. Where do I add that code? Does it go in the functions.php file in the child theme?
Have a good day.
Andrés
Hi there,
Any one of these methods will work: https://docs.generatepress.com/article/adding-php/
Your child theme functions.php file is perfect :)
Thank you, Tom!
Have a good one.
Andrés
No problem! You too :)
Hi Tom,
I'll keep you updated on how the implementation of a third-party filter for posts shows in WPSP goes. That's what the code in this thread is for. It's a work in progress.
Thank you very much for all your help!
Cheers