Results 1 to 2 of 2

Thread: Need a little help with a couple lines of php

  1. #1
    Thread Starter
    0207100's Avatar
    Join Date
    Jun 2013
    Location
    United Kingdom
    Posts
    8
    Thanks
    0
    Thanked 1 Time in 1 Post

    Need a little help with a couple lines of php

    template-tags.php around line 444


    I am looking to only show the ratings if there is a rating or one where the rating is 1 or greater else show nothing.

    I am totally crap at php, I tried a couple things but noting really worked, any help will be greatly appreciated.


    /**
    * Displays listing star rating.
    *
    * @param int $post_id (optional)
    *
    * @return void
    */
    function the_listing_star_rating( $post_id = '' ) {
    $rating = str_replace( '.', '_', va_get_rating_average( $post_id ) );

    if ( '' == $rating ) {
    $rating = '0';
    }
    ?>

    <div class="stars-cont">
    <div class="stars stars-<?php echo $rating; ?>"></div>
    </div>
    <meta itemprop="worstRating" content="1" />
    <meta itemprop="bestRating" content="5" />
    <meta itemprop="ratingValue" content="<?php echo esc_attr( $rating ); ?>" />
    <meta itemprop="reviewCount" content="<?php echo esc_attr( va_get_reviews_count( $post_id ) ); ?>" />
    <?php
    }




    So only when there is a star rating of 1 or above show:

    <div class="stars-cont">
    <div class="stars stars-<?php echo $rating; ?>"></div>
    </div>
    <meta itemprop="worstRating" content="1" />
    <meta itemprop="bestRating" content="5" />
    <meta itemprop="ratingValue" content="<?php echo esc_attr( $rating ); ?>" />
    <meta itemprop="reviewCount" content="<?php echo esc_attr( va_get_reviews_count( $post_id ) ); ?>" />

  2. #2
    joes's Avatar
    Join Date
    Nov 2012
    Location
    Australia
    Posts
    877
    Thanks
    12
    Thanked 358 Times in 261 Posts
    You must be an AppThemes customer and logged in to view this response. Join today!

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. menu 2 -lines why ??
    By enrique_traun in forum Directory
    Replies: 1
    Last Post: June 19th, 2014, 03:57 PM
  2. Jomark Job Title with 2 lines
    By geralweb in forum Help Using JobRoller
    Replies: 1
    Last Post: February 19th, 2014, 09:55 AM
  3. How do i charge per lines ?
    By anilkumarkanneboina in forum ClassiPress General Discussion
    Replies: 2
    Last Post: June 8th, 2013, 10:29 PM
  4. Different buttons, different CSS lines?
    By kortingweb in forum Eva
    Replies: 1
    Last Post: January 13th, 2013, 12:53 AM
  5. Two Lines in the footer
    By rachelragland in forum Report JobRoller Bugs
    Replies: 1
    Last Post: June 28th, 2011, 10:09 PM