• Resolved Quest Realty

    (@quest-realty)


    When I try to add a code for review using schema its showing syntax error in the first lin. But there is no syntax error at all.
    This is the piece of code.

    <div itemscope itemtype=”http://schema.org/Review”&gt;
    <div itemprop=”itemReviewed” itemscope itemtype=”http://schema.org/LocalBusiness”&gt;
    <span itemprop=”name”>Quest Realty</span>
    </div>
    <div itemprop=”name”>Quest-Real Estate Listings, Home for sale, Housing Data</div>
    <div itemprop=”description”>Your destination for all real estate listings and rental properties. Quest-amwaj.com provides comprehensive school and neighborhood information on houses/flats/apartments/commercial areas for rent/sale.</div>
    <div itemprop=”reviewbody”> Quest realty is a reliable real estate agency for renting as well as buying properties.</div>
    <div itemprop=”author” itemscope itemtype=”http://schema.org/Person”>Written by: <span itemprop=”name”>CArrie Hill</span></div>
    <div itemprop=”author” itemscope itemtype=”http://schema.org/Thing”&gt;
    <span itemprop=”name”>Properties in Bahrain</span></div>
    <div><meta itemprop=”datePublished” content=”2015-05-15″>Date Published: 15/05/2015</div>
    <div itemprop=”reviewRating” itemscope itemtype=”http://schema.org/Rating”&gt;
    <meta itemprop=”worstRating” content=”0″><span itemprop=”ratingValue”>4.5</span> / <span itemprop=”bestRating”>5</span> stars</div>
    </div>

    https://ww.wp.xz.cn/plugins/code-snippets/

Viewing 8 replies - 1 through 8 (of 8 total)
  • Plugin Author Shea Bunge

    (@bungeshea)

    The code needs to be valid PHP code, like you could put in a plugin or a theme’s functions.php file.

    Thread Starter Quest Realty

    (@quest-realty)

    okie. thank you

    Thread Starter Quest Realty

    (@quest-realty)

    Can you tell me how to convert this as a valid php code?

    Plugin Author Shea Bunge

    (@bungeshea)

    You can make it into a shortcode:

    add_shortcode( 'schema_data', function () {
        ob_start();
        ?>
    
    <div itemscope itemtype="http://schema.org/Review">
    <div itemprop="itemReviewed" itemscope itemtype="http://schema.org/LocalBusiness">
    <span itemprop="name">Quest Realty</span>
    </div>
    <div itemprop="name">Quest-Real Estate Listings, Home for sale, Housing Data</div>
    <div itemprop="description">Your destination for all real estate listings and rental properties. Quest-amwaj.com provides comprehensive school and neighborhood information on houses/flats/apartments/commercial areas for rent/sale.</div>
    <div itemprop="reviewbody"> Quest realty is a reliable real estate agency for renting as well as buying properties.</div>
    <div itemprop="author" itemscope itemtype="http://schema.org/Person">Written by: <span itemprop="name">CArrie Hill</span></div>
    <div itemprop="author" itemscope itemtype="http://schema.org/Thing">
    <span itemprop="name">Properties in Bahrain</span></div>
    <div><meta itemprop="datePublished" content="2015-05-15">Date Published: 15/05/2015</div>
    <div itemprop="reviewRating" itemscope itemtype="http://schema.org/Rating">
    <meta itemprop="worstRating" content="0"><span itemprop="ratingValue">4.5</span> / <span itemprop="bestRating">5</span> stars</div>
    </div>
    
        <?php
        return ob_get_clean();
    } );

    Then you can use the [schema_data] shortcode in your posts and pages.

    If you’re interested in finding out how this PHP code works, I recommend you read about output buffering and shortcodes.

    Thread Starter Quest Realty

    (@quest-realty)

    when I add this code and activate it in the code snippet area, its showing this meassage: Don’t Panic

    The code snippet you are trying to save produced a fatal error on line 2:

    Can’t use function return value in write context
    The previous version of the snippet is unchanged, and the rest of this site should be functioning normally as before.

    Please use the back button in your browser to return to the previous page and try to fix the code error. If you prefer, you can close this page and discard the changes you just made. No changes will be made to this site.

    Plugin Author Shea Bunge

    (@bungeshea)

    What version of PHP are you using?

    Thread Starter Quest Realty

    (@quest-realty)

    PHP Version 5.4.45

    Plugin Author Shea Bunge

    (@bungeshea)

    Are you sure that this is all of the code that you’re using, and that the error isn’t coming from elsewhere? I have tried running this code multiple times, and I don’t know you could be getting that error from ob_start()

Viewing 8 replies - 1 through 8 (of 8 total)

The topic ‘Showing syntax error’ is closed to new replies.