Page 6 of 8

Re: Wordpress Pagination Links - how do I modify this?

Posted: Mon Sep 18, 2017 2:58 am
by simonmlewis
Wow what a job there. The difficulty I have is in comments.php, I have this:

Code: Select all

			<ul>
			<?php 
                $comments = get_comments(['post_id' => get_the_ID()]);
                $comments = array_filter($comments, function($comment) {
                    return !empty($comment->comment_content);
                });
                
                        wp_list_comments( 'type=comment&callback=blade_grve_comments', $comments); ?>
			</ul>
So not an "ol", tho that's just semantics, but not the rest of the stuff in that tag either.

Re: Wordpress Pagination Links - how do I modify this?

Posted: Mon Sep 18, 2017 3:04 am
by simonmlewis
It also doesn't like starting in the function...

Code: Select all

$defaults['base'] = <span style='color:blue'
The <span. that first < is not liked.

[text]Parse error: syntax error, unexpected '<' in /var/www/vhosts/staging.site.co.uk/httpdocs/wp-content/themes/blade-child/functions.php on line 202
[/text]

Re: Wordpress Pagination Links - how do I modify this?

Posted: Mon Sep 18, 2017 5:16 am
by Celauran
I think that's something that got mangled by the forum software, and I can't seem to post it. That line should be the same as in the original paginate_comments_links function.

Re: Wordpress Pagination Links - how do I modify this?

Posted: Mon Sep 18, 2017 5:29 am
by simonmlewis
can you send me a screenshot of what it should be please? I guess there are double quotes in there?
I can see you have added smurf stuff for fun. Which I guess is to be replaced with 1, 2... etc.

Re: Wordpress Pagination Links - how do I modify this?

Posted: Mon Sep 18, 2017 5:40 am
by Celauran
That's not me having a laugh, that's the forum software filtering out what it thinks is either spam or malicious code. Can't upload a screenshot for some reason, so here's a link: https://imgur.com/gFNIUpG

Re: Wordpress Pagination Links - how do I modify this?

Posted: Mon Sep 18, 2017 5:46 am
by simonmlewis
Oh wow yes I see.

so I added it, and no errors now, but the pagination still appears.
This is the actual code is generates around each number:

Code: Select all

<nav class="woocommerce-pagination"><ul class='page-numbers'>
	<li><span class='page-numbers current'>1</span></li>
	<li><a class='page-numbers' href='http://staging.site.co.uk/product/red-shirt/comment-page-2/#comments'>2</a></li>
	<li><a class='page-numbers' href='http://staging.site.co.uk/product/red-shirt/comment-page-3/#comments'>3</a></li>
	<li><span class="page-numbers dots">&hellip;</span></li>
	<li><a class='page-numbers' href='http://staging.site.co.uk/product/red-shirt/comment-page-10/#comments'>10</a></li>
	<li><a class="next page-numbers" href="http://staging.site.co.uk/product/red-shirt/comment-page-2/#comments">&rarr;</a></li>
</ul>
</nav>
It's doing this when there are no comments (with content).

Re: Wordpress Pagination Links - how do I modify this?

Posted: Mon Sep 18, 2017 5:54 am
by Celauran
The pagination should presumably still appear, just the number of pages should be reduced to the correct amount. I took a fresh install of WordPress, added 400 comments, some with content, some without, and the code I listed now shows 11 pages (20 comments per page) instead of 21, which would be the norm. Does that not line up with what you're seeing? (With adjusted numbers, obviously)

Re: Wordpress Pagination Links - how do I modify this?

Posted: Mon Sep 18, 2017 6:00 am
by simonmlewis
In theory this page should show NO page numbers at all
There are 272 star ratings (no comment text) comments. So the Reviews themselves are empty. But shows the pagination.

Re: Wordpress Pagination Links - how do I modify this?

Posted: Mon Sep 18, 2017 6:01 am
by Celauran
Interesting... Have you inspected the $comments array? Does it contain anything?

Re: Wordpress Pagination Links - how do I modify this?

Posted: Mon Sep 18, 2017 6:07 am
by simonmlewis
It's probably worth saying too that in the view source is has <ul class='page-numbers'> but in comments.php it doesn't have that.
And if I add "<ul class='fred'>", it doesnt render that.

Re: Wordpress Pagination Links - how do I modify this?

Posted: Mon Sep 18, 2017 6:40 am
by Celauran
simonmlewis wrote:It's probably worth saying too that in the view source is has <ul class='page-numbers'> but in comments.php it doesn't have that.
That is useful. Tells us this isn't being rendered by comments.php, but some other file. See if you can track down where these comments are being generated from and we can work from there. Time for me to go to work now, so I probably won't be able to look at this again until tonight.

Re: Wordpress Pagination Links - how do I modify this?

Posted: Mon Sep 18, 2017 6:54 am
by simonmlewis
Will do - leave it with me.

Re: Wordpress Pagination Links - how do I modify this?

Posted: Mon Sep 18, 2017 8:23 am
by simonmlewis
Found the file. IT's in out child theme for single-product-reviews.php.

This is the HTML part:

Code: Select all

			<ol class="commentlist">
				<?php wp_list_comments( apply_filters( 'woocommerce_product_review_list_args', array( 'callback' => 'woocommerce_comments', 'end-callback' => 'jbbg_woocommerce_comments_end' ) ) ); ?>
			</ol>
I tried this but it kept the page number and moved it under comments:

Code: Select all

			<ol class="commentlist">
				<?php
				
				        $comments = get_comments(['post_id' => get_the_ID()]);
                $comments = array_filter($comments, function($comment) {
                    return !empty($comment->comment_content);
                });
                
				 wp_list_comments( apply_filters( 'woocommerce_product_review_list_args',$comments, array( 'callback' => 'woocommerce_comments', 'end-callback' => 'jbbg_woocommerce_comments_end',  ) ) ); ?>
			</ol>

Re: Wordpress Pagination Links - how do I modify this?

Posted: Mon Sep 18, 2017 11:29 am
by Celauran
Looks like you've added $comments to the wrong place in the wp_list_comments call. It needs to be the second argument, so right before the last closing parenthesis. Don't forget you'll also need to swap out calls to pagination methods for the new ones.

Re: Wordpress Pagination Links - how do I modify this?

Posted: Mon Sep 18, 2017 11:35 am
by simonmlewis
Do you mean to add $comments before the final ) ?
What do you mean about swapping out calls ??