Notifications
Clear all

Limited Support

Our support team is currently on holiday from December 25, 2025 to January 7, 2026, and replies may be delayed during this period.

We appreciate your patience and understanding while our team is away. Thank you for being part of the wpForo community!

Merry Christmas and Happy Holidays! 🎄

Script [Closed] is there a hook to add content before comments area?

9 Posts
4 Users
1 Reactions
2,156 Views
Posts: 4
Topic starter
(@newuser20)
Active Member
Joined: 4 years ago

is there a hook to add content before comments area?


8 Replies
Chris
Posts: 3610
(@chris)
Famed Member
Joined: 4 years ago

Hi @newuser20,

You want a hook under the first post or under all replies?


Posts: 4
Topic starter
(@newuser20)
Active Member
Joined: 4 years ago

Hello @Chris

thank you for reply

i want a hook under the first post


4 Replies
Tutrix
(@tutrix)
Joined: 6 years ago

Noble Member
Posts: 1521
Posted by: @newuser20

i want a hook under the first post

You can use the Code Snippets plugin

create a new snippet with this code

add_action( 'wp_head', function () { ?>
<script>
jQuery(document).ready(function(){
jQuery( '<div class="content-after-first-post">Insert here the content to be displayed after the first post</div>' ).insertAfter( "#wpforo #wpforo-wrap .post-wrap.wpfp-first" );
});
</script>
<?php } );

add this to custom css (is only an example)

.content-after-first-post {
background: #f00;
color: #fff !important;
padding: 10px !important;
margin: 10px auto !important;
font-size: 18px !important;
}

Dashboard > Forums > Settings > Style (custom css)


Chris
(@chris)
Joined: 4 years ago

Famed Member
Posts: 3610

@newuser20,

Insert the bellow code in \wp-content\themes\ActiveTheme\functions.php file

add_action('wpforo_loop_hook', function($key){
    if( $key === 0 ){
        echo 'Your text Here';
    }
});

 


(@newuser20)
Joined: 4 years ago

Active Member
Posts: 4

@chris 

it working but the content appear in every page 

is there a way to show the content in post pages only?


Chris
(@chris)
Joined: 4 years ago

Famed Member
Posts: 3610

@newuser20,

Remove the Hook I gave you, Read this doc about theme customization:

https://wpforo.com/docs/root/forum-themes/theme-customization/

You need to customize wpForo theme to get the result you want.


Posts: 4
Topic starter
(@newuser20)
Active Member
Joined: 4 years ago

how to detect if current page is a post page and how to get all post information?


1 Reply
Robert
Admin
(@robert)
Joined: 10 years ago

Support Team
Posts: 10606

@newuser20,

Here is the code provided by @chris and modified to work only on the posts page:

add_action('wpforo_loop_hook', function($key){
if( function_exists('WPF') && WPF()->current_object['template'] === 'post' && $key === 0 ){
echo 'Your text Here';
}
});