Site logo

Archived topic

Adding Hooks After Content

7 replies · Started by Sarah on August 8, 2019

Viewing posts 1–8 of 8

Hi, on single posts (articles/blog), I want to add a horizontal rule directly after the article content, followed by related articles, followed by the next/previous post links.

I've read through several posts and it looks like I should be able to create two hooks using after_content with the second having priority set to 15 (https://generatepress.com/forums/topic/i-need-help-in-positioning-ads-on-single-posts-page/).

I added one hook to display a horizontal rule using after_content and displaying on all singular but even with the related images turned off, it displays the horizontal rule below the next/previous post links - how do I fix that?

I am using Related Posts Thumbnails by WPBrigade plugin. I have the option to automatically append to the post content or use the following snippet in The Loop <?php get_related_posts_thumbnails(); ?>

I have chosen the option to use the snippet but I have no clue about writing php - can you help at all so I can then create a hook to display it after the horizontal rule?

Thank you for your help!
Sarah :)

Hi there,

simpler solution is to use some CSS to add a border to the top of the Related Posts container with a little bit of extra padding like so:

.relpost-thumb-wrapper {
    padding-top: 25px;
    border-top: 1px solid #ddd;
}

David, that is brilliant! Thank you :D

Glad to be of help.

I'm facing an issue related to that same 'after_content' hook.

I want to display "Last updated" date after content but before 'next' and 'previous' links. With the following code, utilizing the after_content hook, I get the last updated date displayed right below the 'next' and 'previous' links. I want the opposite.

<?php if ( is_single() ) { 
    if ( get_the_time( 'U' ) !== get_the_modified_time( 'U' ) ) {
        $time_string = '<time class="last-updated" datetime="' . esc_attr( get_the_modified_date( 'c' ) ) . '" itemprop="dateModified">' . esc_html( get_the_modified_date() ) . '</time>';
        echo 'Updated on ' . $time_string;
    }
} ?>

Any chance you can open a new topic for your question and link us to the page in question?

Thanks!

Thanks!

This archived topic is closed to new replies.