Notifications
Clear all

Limited Support

Our team is currently on holiday, so support will be limited during this period. Response times may be slower than usual, and some inquiries may be delayed.
We appreciate your patience and understanding, and we’ll resume our usual support by the end of August.

 

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

9 Posts
4 Users
1 Reactions
1,712 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: 3611
(@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: 5 years ago

Noble Member
Posts: 1522
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: 3611

@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: 3611

@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: 9 years ago

Support Team
Posts: 10616

@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';
}
});