• Resolved Joan

    (@joandelfin)


    Hello!

    First, thank you again for this plugin, it is awesome.

    My question is if by using the function glsr_get_reviews() I can add some arguments to just retrieve reviews that have content or title.

    Thank you!

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

    (@geminilabs)

    With content AND title:

    function glsr_has_content_and_title($and, $handle) {
        if ('query-review-ids' === $handle) {
            $and['content_title'] = "AND (p.post_content <> '' AND p.post_title <> '')";
        }
        return $and;	
    }
    
    // 1. Filter the SQL query
    add_filter('site-reviews/query/sql/and', 'glsr_has_content_and_title', 10, 2);
    
    // 2. Get your reviews
    $reviews = apply_filters('glsr_get_reviews', []);
    
    // 3. Remove the SQL query filter
    remove_filter('site-reviews/query/sql/and', 'glsr_has_content_and_title');
    

    With content OR title:

    function glsr_has_content_or_title($and, $handle) {
        if ('query-review-ids' === $handle) {
            $and['content_title'] = "AND (p.post_content <> '' OR p.post_title <> '')";
        }
        return $and;	
    }
    
    // 1. Filter the SQL query
    add_filter('site-reviews/query/sql/and', 'glsr_has_content_or_title', 10, 2);
    
    // 2. Get your reviews
    $reviews = apply_filters('glsr_get_reviews', []);
    
    // 3. Remove the SQL query filter
    remove_filter('site-reviews/query/sql/and', 'glsr_has_content_or_title');
    Thread Starter Joan

    (@joandelfin)

    Thank you so much, it worked!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Querying reviews that have title and content’ is closed to new replies.