Page 1 of 1

Wordpress: Can you query Anonymous comments?

Posted: Tue Apr 03, 2018 6:31 am
by simonmlewis
We have a commerce site that imported 10,000s of star ratings, and they were added in the Reviews section.

We have decided to see if we can query the review, and if it is Anonymous, which these all are, then to hide the 'author', remove the date (as they are all the same date), and add text to say "Star rating only given".

If reviews have an author, then it will show everything.

I don't know how to even start to accomplish this. ie. is it in single-product.php or review.php. Once would thing it would be a function we need to write, but no idea how to.

Re: Wordpress: Can you query Anonymous comments?

Posted: Tue Apr 03, 2018 3:59 pm
by protopatterns
I assume this is WooCommerce ('single-product.php'). Why not start with the db?

The users themselves:
https://deanandrews.uk/export-woocommer ... wordpress/

And the ratings:
https://wordpress.stackexchange.com/que ... est-design

You can remove the author (etc) in your theme itself, here: wp-content/themes/[theme-name]/inc/template-tags.php

Just modify 'function themename_posted_on()' right before the end, e.g.:

Code: Select all

    // Very bottom of 'theme_name_posted_on()':
    $anonymous = get_the_author();
        if ( $anonymous == "Anonymous" ) {
            // remove author, date, etc.
    } else {	
    $byline = sprintf(
        /* translators: %s: post author. */
        // ...
    }
} // End function
[ /syntax]