[Resolved] I Need Help in Positioning Ads on Single Posts Page

Home Forums Support [Resolved] I Need Help in Positioning Ads on Single Posts Page

Home Forums Support I Need Help in Positioning Ads on Single Posts Page

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #821615
    Jericho

    Hi Tom and Team,

    Can you please help me place my ads just before the Related post section of my single post page?

    Screenshot: https://prnt.sc/mq6nia

    I try to use after_content Hook but the ads apear just below the related posts.

    Thanks very much!
    Jericho

    #821617
    Jericho

    By the way, I’m using Jetpack Related Posts just in case you want know.

    Thanks!

    #821822
    David
    Staff
    Customer Support

    Hi there,

    Not sure about this but give this a shot – add this PHP snippet:

    function jp_remove_related() {
     $jprp = Jetpack_RelatedPosts::init();
     $callback = array( $jprp, 'filter_add_target_to_dom' );
     remove_filter( 'the_content', $callback, 40 );
    }
     
    add_filter('wp', 'jp_remove_related', 20);

    This should remove the Related posts from the content.

    Now create 2 hooks, both of which will be using the after_content hook.

    Hook 1 will contain your Ads code
    Hook 2 will contain the related posts shortcode below, for this hook set the priority to 15:

    [jetpack-related-posts]

    #821887
    Jericho

    Thanks, David!

    This hack works!

    #821898
    David
    Staff
    Customer Support

    Awesome – glad to be of help.

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