I am currently hooking on the_content() but that goes through the WordPress loop too. How can I only hook on the Single.php page?

Also, is there a way to only look on the first X posts in the WordPress loop?

By the way, I am creating a plugin

2 s
2

This will handle appending the content to single posts:

function yourprefix_add_to_content( $content ) {    
    if( is_single() ) {
        $content .= 'Your new content here';
    }
    return $content;
}
add_filter( 'the_content', 'yourprefix_add_to_content' );

Leave a Reply

Your email address will not be published. Required fields are marked *