• Resolved ethan11698

    (@ethan11698)


    Is there a way to display the overall star rating in the excerpt before you click read more? Is there also a way to pin the top 5 reviewed categories? For example top 5 reviewed products

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author Gemini Labs

    (@geminilabs)

    1. Please see: https://pastebin.com/0Bn8fnZe

    2. For pointers on how to sort your products by rating, please see: https://www.ads-software.com/support/topic/order-custom-post-according-to-assigned-reviews-on-archive-page/

    • This reply was modified 4 years, 7 months ago by Gemini Labs.
    Thread Starter ethan11698

    (@ethan11698)

    I added the code to my theme’s php file and it didn;t work. However, I am using
    the plugin WP Blog and Widget to display these posts so I am unsure if this is the reason.

    Plugin Author Gemini Labs

    (@geminilabs)

    For reference, here is the code from the pastebin link:

    /**
     * Prefix the page/post excerpt with the Site Reviews rating summary
     * Paste this in your active theme's functions.php file.
     * @param string $excerpt
     * @param \WP_Post $post
     * @return string
     */
    add_filter('get_the_excerpt', function ($excerpt, $post) {
        $postTypes = ['page','post']; // Replace the values in this array with the desired post_types
        if (in_the_loop() && in_array($post->post_type, $postTypes)) {
            $shortcode = '[site_reviews_summary assigned_to=post_id hide=bars,summary,if_empty]';
            return do_shortcode($shortcode).$excerpt;
        }
        return $excerpt;
    }, 10, 2);

    Notice that the code uses the in_the_loop function to check that it is only run in The Loop.

    Since you are using a widget to display your post excerpts, it will not be using “The Loop”.

    You can either remove this check:

    if (in_array($post->post_type, $postTypes)) {
    

    Or you can change it to only work if it is not in The Loop:

    if (!in_the_loop() && in_array($post->post_type, $postTypes)) {
    

    Also, you will want to make sure that you have changed this line to only include the post types that you want:

    $postTypes = ['page','post']; // Replace the values in this array with the desired post_types
    
    • This reply was modified 4 years, 7 months ago by Gemini Labs.
    Thread Starter ethan11698

    (@ethan11698)

    I have tried the solutions posted for example

    add_filter(‘get_the_excerpt’, function ($excerpt, $post) {
    $postTypes = [‘blog_post’]; // Replace the values in this array with the desired post_types
    $shortcode = ‘[site_reviews_summary assigned_to=post_id hide=bars,summary,if_empty]’;
    return do_shortcode($shortcode).$excerpt;
    return $excerpt;
    }, 10, 2);

    and

    /**
    * Prefix the page/post excerpt with the Site Reviews rating summary
    * Paste this in your active theme’s functions.php file.
    * @param string $excerpt
    * @param \WP_Post $post
    * @return string
    */
    add_filter(‘get_the_excerpt’, function ($excerpt, $post) {
    $postTypes = [‘blog_post’]; // Replace the values in this array with the desired post_types
    if (!in_the_loop() && in_array($post->post_type, $postTypes)) {
    $shortcode = ‘[site_reviews_summary assigned_to=post_id hide=bars,summary,if_empty]’;
    return do_shortcode($shortcode).$excerpt;
    }
    return $excerpt;
    }, 10, 2);

    But nothing appears to show up in the excerpt. I’m unsure whether the plugin is not allowing me to post to the excerpt or my post type is incorrect, I found the post type in the plugins php file.

    Plugin Author Gemini Labs

    (@geminilabs)

    If you have added a custom excerpt to each of your blog_posts, then the following code should work:

    /**
     * Prefix the page/post excerpt with the Site Reviews rating summary
     * Paste this in your active theme's functions.php file.
     * @param string $excerpt
     * @param \WP_Post $post
     * @return string
     */
    add_filter('get_the_excerpt', function ($excerpt, $post) {
        if ('blog_post' === $post->post_type) {
            $shortcode = '[site_reviews_summary assigned_to=post_id hide=bars,summary]';
            return do_shortcode($shortcode).$excerpt;
        }
        return $excerpt;
    }, 10, 2);

    If you have not manually saved a custom except on each blog_post, then this will not work as that plugin generates its own excerpt from the content.

    For additional assistance, please contact the support team of the WP Blog and Widget plugin directly. Thanks.

    @wponlinesupport

    Thread Starter ethan11698

    (@ethan11698)

    This solved it thank you for your help!

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Review help’ is closed to new replies.