Site logo

Archived topic

"After Content" hook is displayed below every item on search results page

1 reply · Started by Dominique on June 28, 2018

Viewing posts 1–2 of 2

Hi,

I use the 'after content' hook to help with site navigation and to display ads. It all works fine except that the hook's content appears below every item in the search results page.

So my search results page is a list of:
- Page Title
- Excerpt (read more)
- Hook

- Page Title
- Excerpt (read more)
- Hook

...

Is there a way to fix that behaviour so that the hook is not displayed in the results page below every item?

I thought of using the 'Before Footer' hook instead but that is not ideal for a variety of reasons...

You can wrap the content inside the hook within a conditional tag:

https://docs.generatepress.com/article/using-hooks-conditional-tags/

An example for displaying it only on the a page or a single post can be achieved like so:

<?php if ( is_single() || is_page() ) : ?>
    This Content will ONLY show in single posts or pages.
<?php endif; ?>
This archived topic is closed to new replies.