[Support request] Custom print line in 'content-page' help

Home Forums Support [Support request] Custom print line in 'content-page' help

Home Forums Support Custom print line in 'content-page' help

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #754843
    Adam

    I needed to add a disclosure statement into pages on my site so the solution I came up with was to add a printf line inside of the theme file ‘content-page’ at the bottom of the entry-content section shown below. This works for me, but I would like to not print this on select pages or at least not on the home page. Could you recommend the code for this, I was trying some IF statements but unsuccessfully – or – if you have a better place to put this, that would be great.

    <?php
    the_content();

    wp_link_pages( array(
    ‘before’ => ‘

    ‘,
    ) );
    printf( ‘<span class=”aff_disc”>This post may contain affiliate links, see our disclosure</span>’
    );
    ?>

    <!– .entry-content –>

    #755049
    Tom
    Lead Developer
    Lead Developer

    Hi there,

    It’s likely better to use a Hook Element for this.

    You could use the generate_after_content hook and then set the Display Rules to whatever you need.

    #755072
    Adam

    I was able to use the generate_after_content hook to do this, but I don’t see options to turn it on or off within a specific page. Maybe I am not seeing it. I currently have the hook disabled.

    #755080
    Tom
    Lead Developer
    Lead Developer

    You can exclude specific pages inside the Display Rules area: https://docs.generatepress.com/article/hooks-element-overview/#display-rules

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