Wordpress Pagination Links - how do I modify this?

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

simonmlewis
DevNet Master
Posts: 4435
Joined: Wed Oct 08, 2008 3:39 pm
Location: United Kingdom
Contact:

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

Post by simonmlewis »

But why is it now doing that - if I switch it back to the previous function and file, it doesn't do it. Is something in there making them all appear when they shouldn't?
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

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

Post by Celauran »

Apparently. You'd need to dig through the code and find where get_comments is being called, and with which arguments. You can pull those arguments up to your get_comments call if you like, or you can modify whatever function calls get_comments by default and pull all of our changes higher. Either way seems fine, but the latter is obviously going to be more work.
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

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

Post by Celauran »

https://codex.wordpress.org/Function_Re ... t_comments

Looks like the status argument is what you're after.
simonmlewis
DevNet Master
Posts: 4435
Joined: Wed Oct 08, 2008 3:39 pm
Location: United Kingdom
Contact:

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

Post by simonmlewis »

I don't see that argument in the new code. What's puzzling me is why the 'NEW' code is "unlocking" the standard feature of showing only comments that are approved.
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

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

Post by Celauran »

simonmlewis wrote:I don't see that argument in the new code.
That was my point.
simonmlewis wrote:What's puzzling me is why the 'NEW' code is "unlocking" the standard feature of showing only comments that are approved.
Because we're overriding the default behaviour in order to accomplish a set of goals the default behaviour doesn't allow for. We're necessarily doing things differently. Adding that missing key to the get_comments in the modified code should resolve the issue.
simonmlewis
DevNet Master
Posts: 4435
Joined: Wed Oct 08, 2008 3:39 pm
Location: United Kingdom
Contact:

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

Post by simonmlewis »

Adding it where....??
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

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

Post by Celauran »

Do you see where post_id gets passed into get_comments? Just add another key/value pair to that array.
simonmlewis
DevNet Master
Posts: 4435
Joined: Wed Oct 08, 2008 3:39 pm
Location: United Kingdom
Contact:

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

Post by simonmlewis »

Code: Select all

$comments = get_comments(['post_id' => get_the_ID()] ['post_id' => get_the_ID()]);
Changing the last bit ??
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

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

Post by Celauran »

simonmlewis wrote:

Code: Select all

$comments = get_comments(['post_id' => get_the_ID()] ['post_id' => get_the_ID()]);
Changing the last bit ??
That's the right spot, but that syntax is no good and you're missing the status key. Try something like this

Code: Select all

$comments = get_comments(['post_id' => get_the_ID(), 'status' => 'approve']);
simonmlewis
DevNet Master
Posts: 4435
Joined: Wed Oct 08, 2008 3:39 pm
Location: United Kingdom
Contact:

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

Post by simonmlewis »

Gotcha. Can you see why when they post the comment it now doesn't show their 'own' new comment waiting for moderation?
It use to do that as a way of saying "we have it, just needs moderating".
I'm sure it's something down in that function that at the moment shows only if it's live.
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
Post Reply