how can I remove the "#comments" behind the comments pagination link generally ?

At themoment it gives out links like: /comment-page-3/#comments I wanna have it clrea like this: /comment-page-3/

  • Please read How to Ask. Tell us what you have tried and what your research efforts are. I wanna X. is not a question. – fuxia Oct 30 '16 at 21:58
  • I tryed nothing, because I have no plan how to remo this "#comments" generally ? Dont know where its definated – RodneyHawk Oct 30 '16 at 22:00
  • Then look at the source code in WordPress like everybody else. – fuxia Oct 30 '16 at 22:00
  • I was googeling now about 1 hour but I didnt find any reference where this is definated – RodneyHawk Oct 30 '16 at 22:04
  • The source code in WordPress. You do have a copy of WordPress on your computer, right? – fuxia Oct 30 '16 at 22:06

Somewhere in your theme template is a call to the_comments_pagination(). If you would look at the source code, you could find the declaration of that function:

function the_comments_pagination( $args = array() ) {
    echo get_the_comments_pagination( $args );

There are two things to note here:

  1. This function is passing its call through to another function.
  2. It accepts a parameter $args.

Looking at the called function get_the_comments_pagination() shows you that the markup is built using paginate_comments_links( $args ). So the $args are passed through again.

And in that function you can see what happens with the parameter: It is parsed against a default value.

    'base' => add_query_arg( 'cpage', '%#%' ),
    'format' => '',
    'total' => $max_page,
    'current' => $page,
    'echo' => true,
    'add_fragment' => '#comments'

In conclusion, you just have to change the call to the first function:

the_comments_pagination([ 'add_fragment' => '' ]);
  • Ahhhh I understang...ok...many thanks...so until now I only user the standrt navigation (without 1,2,3,4) because of the reason, that I dont know, how to reverse the numbers, becose they are count from back to fron and with the highes number they make duplicate content...So for that I will make an new question (sorry Iam new here, dont know exactly all rules) – RodneyHawk Oct 30 '16 at 22:33
  • To that one Questin more pleas: The headline "Comments Pagination" does even come from this. How to filter this that its away ? In the Template its not ! – RodneyHawk Oct 30 '16 at 23:55
  • @RodneyHawk Again, see the source. It is the argument 'screen_reader_text'. – fuxia Oct 31 '16 at 0:13
  • Yes I know...i told before that that is in this . But how to filter it out ? – RodneyHawk Oct 31 '16 at 2:29
  • @RodneyHawk Pass it as an empty string to the arguments. There is no need to "filter it out". – fuxia Oct 31 '16 at 2:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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