Archived topic
Custom print line in 'content-page' help
3 replies · Started by Adam on December 12, 2018
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.
the_content();
wp_link_pages( array(
'before' => '
'after' => '
',
) );
printf( '<span class="aff_disc">This post may contain affiliate links, see our disclosure</span>'
);
?>
<!-- .entry-content -->
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.
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.
You can exclude specific pages inside the Display Rules area: https://docs.generatepress.com/article/hooks-element-overview/#display-rules