[Resolved] Adding Hooks After Content

Home Forums Support [Resolved] Adding Hooks After Content

Home Forums Support Adding Hooks After Content

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #978975
    Sarah

    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 ๐Ÿ™‚

    #978980
    David
    Staff
    Customer Support

    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;
    }
    #980731
    Sarah

    David, that is brilliant! Thank you ๐Ÿ˜€

    #980802
    David
    Staff
    Customer Support

    Glad to be of help.

    #1286131
    litesprint

    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;
        }
    } ?>
    #1286132
    Leo
    Staff
    Customer Support

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

    Thanks!

    #1286208
    litesprint
    #1286213
    Leo
    Staff
    Customer Support

    Thanks!

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