0

I want to show the_content() only in The first page of each post, and I don't want to show the_content() in comment-page when "Break comments into pages..." enabled.

Is there a Way?

enter image description here









enter image description here

1 Answer 1

0

For comment pages, the WP_Query-var cpage is set, telling us which comment page we're on, making it is possible to filter the content for comment pages like this:

add_filter('the_content', 'comment_page_hide_content');
function comment_page_hide_content($content) {
    global $wp_query;
    if ($wp_query->get('cpage') > 1){ // Greater than one, because 1 inducates the first comment page
        $content = "";
    }
    return $content;
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.