Comment Navigation Appears Twice After Moving Comment Form
-
Hi GeneratePress team,
I moved the comment form to the top using hooks and custom CSS. Everything works correctly, but the “Older Comments” and “Newer Comments” navigation is displayed twice.
I only want a single comment navigation section without duplicates.
Here is the customization I currently use:
<?php
/**
add_action( 'wp', function() {
// 1. Hapus form dari posisi default (bawah)
remove_action( 'generate_after_do_template_part', 'generate_do_comments_template', 15 );
// 2. Pasang kembali di posisi atas (sebelum container komentar)
// Kita panggil fungsi asli GP tapi biarkan sistem yang kirim argumennya
add_action( 'generate_before_comments_container', 'generate_do_comments_template' );
});
/**
add_action( 'wp_head', function() {
?>
<style>
#comments {
display: flex !important;
flex-direction: column !important;
}
#respond {
order: -1 !important;
margin-bottom: 30px !important;
border-bottom: 2px solid #eeeeee;
padding-bottom: 20px !important;
}
.comments-title, .comment-list, .comment-navigation {
order: 1 !important;
}
.comment-form {
display: grid !important;
grid-template-columns: repeat(2, 1fr);
gap: 15px;
}
.comment-form-comment, .custom-comment-notes, .form-submit, .comment-form-cookies-consent {
grid-column: span 2;
}
@media (max-width: 768px) {
.comment-form { grid-template-columns: 1fr; }
.comment-form-comment, .comment-form-author, .comment-form-email { grid-column: span 1; }
}
</style>
<?php
});
/**
add_filter( 'comment_form_defaults', function( $defaults ) {
$defaults['comment_notes_before'] = '
<div class="custom-comment-notes" style="margin-bottom:15px; font-size:14px; color:#aaa;">
<p>Gunakan email valid agar kamu mendapat notifikasi balasan.</p>
<p>Kirim <a href="https://prnt.sc/" target="_blank" rel="nofollow noopener noreferrer" style="color:#0033ff;">screenshot</a> komentar kamu di sini.</p>
</div>';
return $defaults;
});
/**
add_filter( 'comment_form_fields', function( $fields ) {
if(isset($fields['comment'])) {
$comment_field = $fields['comment'];
unset( $fields['comment'] );
$fields['comment'] = $comment_field;
}
return $fields;
});
?>I also use custom CSS to reorder the comment form visually.
Screenshot: https://prnt.sc/UB-r80GHammoCould you please check the correct method to prevent duplicate comment navigation in this setup?
Thank you.
The page I need help with: [log in to see the link]
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
You must be logged in to reply to this topic.
