• Resolved bartdenhartog

    (@bartdenhartog)


    Hi,

    I’m developing a custom theme with ACF and I’ve a question:

    Via ACF I’ve made a flexible content block where the client can select a review in the backend of the site to display in on the front-end.

    Now I already have can display the_title & the_content but I also need the person’s name and the star-rating.

    How can I display this? Example below:

    <?php 
                    if( $post_objects ): ?>
                        <?php $delay_count = 0; ?>
                        <?php foreach( $post_objects as $post):?>
                            <?php setup_postdata($post); ?>
                
                                        
                            <div class="col-10 col-sm-10 col-md-8 col-lg-8" data-aos="fade-up" data-aos-delay="<?php echo $delay_count * 200; ?>">
                                <?php echo the_title(); ?>
                                <?php echo the_content(); ?>
                            </div>
                            
            
                        <?php $delay_count++; ?>
                        <?php endforeach; ?>
    
                    <?php wp_reset_postdata(); ?>
                <?php endif; ?>
Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Gemini Labs

    (@geminilabs)

    <?php
    
    // Get the review object (assuming that $post is a review post_type)
    $review = apply_filters( 'glsr_get_review', null, $post->ID );
    
    // Print the rendered (HTML) review to the page
    echo $review;
    
    // OR, print a raw (unrendered) value, for example the author name
    echo $review->author;
    
    // OR, print a rendered value, for example, the author name
    $reviewHtml = $review->build();
    echo $reviewHtml->author; 
    
    // You can also print the entire PHP $review object (and rendered HTML) to the screen for debugging
    glsr_debug( $review, $reviewHtml );
    
    // You can also render the star rating like this:
    echo '<div class="glsr-default">';
    echo apply_filters( 'glsr_star_rating', null, $review->rating );
    echo '</div>';
    

    For more information, please see the Site Reviews > Documentation > Functions page.

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

    (@bartdenhartog)

    Thanks for the quick response! It works perfectly, thank you!

    Plugin Author Gemini Labs

    (@geminilabs)

    You may also want to first check that the review has been correctly fetched:

    if( $review = apply_filters( 'glsr_get_review', null, $post->ID )) {
        // use the review values here
    }
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘ACF post object’ is closed to new replies.