[Resolved] How to Add HTML in Child Theme

Home Forums Support [Resolved] How to Add HTML in Child Theme

Home Forums Support How to Add HTML in Child Theme

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #1404359
    Andres

    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!

    #1404509
    David
    Staff
    Customer Support

    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>';
    });
    #1405283
    Andres

    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

    #1405383
    Tom
    Lead Developer
    Lead Developer

    Hi there,

    Any one of these methods will work: https://docs.generatepress.com/article/adding-php/

    Your child theme functions.php file is perfect 🙂

    #1408323
    Andres

    Thank you, Tom!

    Have a good one.

    Andrés

    #1408360
    Tom
    Lead Developer
    Lead Developer

    No problem! You too 🙂

    #1408364
    Andres

    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

Viewing 7 posts - 1 through 7 (of 7 total)
  • You must be logged in to reply to this topic.