The effects of alcohol on
sustanon 250 leucine for – real weight loss & bodybuilding benefits?
[Solved] filter comment with custom field
✦ Summarize Topic
✦
✦
✦
AI is analyzing the discussion...
How-to and Troubleshooting
Topic starter
Translate
▼
English
Spanish
French
German
Italian
Portuguese
Russian
Chinese
Japanese
Korean
Arabic
Hindi
Dutch
Polish
Turkish
Vietnamese
Thai
Swedish
Danish
Finnish
Norwegian
Czech
Hungarian
Romanian
Greek
Hebrew
Indonesian
Malay
Ukrainian
Bulgarian
Croatian
Slovak
Slovenian
Serbian
Lithuanian
Latvian
Estonian
Show original
Translating...
Jan 12, 2022 1:45 pm
(@vahid13713)
Active Member
Joined: 4 years ago
Hello, How can I filter the comments displayed under a page based on a custom field? For example, if the custom field has a value of a, that comment should be displayed, and if it does not have this value, it should not be displayed.
Support
Translate
▼
English
Spanish
French
German
Italian
Portuguese
Russian
Chinese
Japanese
Korean
Arabic
Hindi
Dutch
Polish
Turkish
Vietnamese
Thai
Swedish
Danish
Finnish
Norwegian
Czech
Hungarian
Romanian
Greek
Hebrew
Indonesian
Malay
Ukrainian
Bulgarian
Croatian
Slovak
Slovenian
Serbian
Lithuanian
Latvian
Estonian
Show original
Translating...
Jan 12, 2022 2:23 pm
(@asti)
Illustrious Member
Joined: 8 years ago
vahid13713,
If you're a developers you can use the get_comments() and get_comment() functions.
Also, we have plugin customization and custom addon development services at the gVectors Team. They can assess the work and create it for you. Just contact us via sales[at]gvectors.com email address and send a list of requirements you'd like to have.
(@vahid13713)
Joined: 4 years ago
Active Member
Posts: 4
Jan 13, 2022 9:48 am
Translate
▼
English
Spanish
French
German
Italian
Portuguese
Russian
Chinese
Japanese
Korean
Arabic
Hindi
Dutch
Polish
Turkish
Vietnamese
Thai
Swedish
Danish
Finnish
Norwegian
Czech
Hungarian
Romanian
Greek
Hebrew
Indonesian
Malay
Ukrainian
Bulgarian
Croatian
Slovak
Slovenian
Serbian
Lithuanian
Latvian
Estonian
Show original
Translating...
@asti
Hello asti and thank you very much for your answer
I am a developer.
I get the comment with the get_comments() function and I want wpdiscuz to show only the comments I received. How can I do this? Please provide me with a sample code
my sample code:
$comments20 = get_comments (array ('meta_key'=> 'keytoopurl', 'meta_value'=> 'y'));
I want wpdiscuz to display only variable comments20
How can I do this?
Thanks for your cooperation
(@asti)
Joined: 8 years ago
Illustrious Member
Posts: 8208
Jan 13, 2022 3:41 pm
Translate
▼
English
Spanish
French
German
Italian
Portuguese
Russian
Chinese
Japanese
Korean
Arabic
Hindi
Dutch
Polish
Turkish
Vietnamese
Thai
Swedish
Danish
Finnish
Norwegian
Czech
Hungarian
Romanian
Greek
Hebrew
Indonesian
Malay
Ukrainian
Bulgarian
Croatian
Slovak
Slovenian
Serbian
Lithuanian
Latvian
Estonian
Show original
Translating...
@vahid13713,
Please use this code:
add_action('pre_get_comments', function ($queryObj) {
$vars = $queryObj->query_vars;
$vars['meta_key'] = 'keytoopurl';
$vars['meta_value'] = 'y';
$queryObj->query_vars = $vars;
});
(@vahid13713)
Joined: 4 years ago
Active Member
Posts: 4
Jan 15, 2022 10:43 am
Translate
▼
English
Spanish
French
German
Italian
Portuguese
Russian
Chinese
Japanese
Korean
Arabic
Hindi
Dutch
Polish
Turkish
Vietnamese
Thai
Swedish
Danish
Finnish
Norwegian
Czech
Hungarian
Romanian
Greek
Hebrew
Indonesian
Malay
Ukrainian
Bulgarian
Croatian
Slovak
Slovenian
Serbian
Lithuanian
Latvian
Estonian
Show original
Translating...
@asti
Thank you very much for your answer
I tested this code but it does not work. All comments are displayed!
(@vahid13713)
Joined: 4 years ago
Active Member
Posts: 4
Jan 15, 2022 6:36 pm
Translate
▼
English
Spanish
French
German
Italian
Portuguese
Russian
Chinese
Japanese
Korean
Arabic
Hindi
Dutch
Polish
Turkish
Vietnamese
Thai
Swedish
Danish
Finnish
Norwegian
Czech
Hungarian
Romanian
Greek
Hebrew
Indonesian
Malay
Ukrainian
Bulgarian
Croatian
Slovak
Slovenian
Serbian
Lithuanian
Latvian
Estonian
Show original
Translating...
@asti
Hi, I have fixed the problem. I am posting content for others to use.
Your plugin caches comments, which is why our code does not work. Also, after writing the filter, it is necessary to activate and deactivate the plugin once. The problem was solved by adding the following line of code.
add_action('pre_get_comments', function ($query)
{
$query->query_vars['meta_query'] = [
[
'key' => 'keyurl',
'value' => "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]"
]
];
}, 10, 1);