• Resolved mrosch

    (@mrosch)


    I really love your plugin, it’s exactly what I was looking for! There is only one thing missing: On my blog, I’m reviewing Apps and therefore it would be great to have the star rating only for posts in the review category. Is there an easy hack to do this? One guy who wrote a review about your plugin mentioned he did exactly that but unfortunately he didn’t share the code so far…

    http://wordpress.org/extend/plugins/the-seo-rich-snippets/

Viewing 1 replies (of 1 total)
  • Thread Starter mrosch

    (@mrosch)

    ok, I’m not a developer but I figured it our myself. The code might be horrible but it works. 😉

    Just let me share this with you – look for “function add_footer_snippets()” in “the-seo-rich-snippets/theseorichsnippets.php” and change it to this:

    function add_footer_snippets() {
    if (is_home()){
    }
    else{
    if (in_category('14')) {
    	$__rich_name = get_option('snippet_home_name');
    	$__rich_address = get_option('snippet_home_address');
    	$__rich_local = get_option('snippet_home_local');
    	$__rich_region = get_option('snippet_home_region');
    	$__rich_url = get_option('snippet_home_url');
    	$__rich_reviewer = get_option('snippet_home_reviewer');
    	$__rich_value = get_option('snippet_home_value');
    	$__rich_best = get_option('snippet_home_best');
    	?>
        <div id="RichSnippets" style="display:none;">
            <div itemscope="" itemtype="http://data-vocabulary.org/Review">
                <span itemprop="itemreviewed" itemscope="" itemtype="http://data-vocabulary.org/Organization">
                    <span itemprop="name"><?php echo $__rich_name;?></span>
                    <?php _e('located at','tsrtext');?>
                    <span itemprop="address" itemscope="" itemtype="http://data-vocabulary.org/Address">
                        <span itemprop="street-address"><?php echo $__rich_address;?></span>
                        ,
                        <span itemprop="locality"><?php echo $__rich_local;?></span>,
                        <span itemprop="region"><?php echo $__rich_region;?></span>
                    </span>
                    <span style="display:none;">
                        <a href="<?php echo $__rich_url;?>" itemprop="url"><?php echo $__rich_url;?></a>
                    </span>
                </span>
                . <?php _e('Reviewed by','tsrtext');?>
                <span itemprop="reviewer"><?php echo $__rich_reviewer;?></span>
                <?php _e('rated:','tsrtext');?>
                <span itemprop="rating" itemscope="" itemtype="http://data-vocabulary.org/Rating">
                    <span itemprop="value"><?php echo $__rich_value;?></span>
                    /
                    <span itemprop="best"><?php echo $__rich_best;?></span>
                </span>
            </div>
        </div>
        <style>
    		#RichSnippets { text-align:center; margin:auto;}
    	</style>
        <?
    }
    }
    }

    This change does 3 things:
    1. It hides the review text at the footer of each page (so it shows up in Google only)
    2. It doesn’t show ratings on the homepage in Google
    3. It only shows the rating stars in the review category (in my case this one has the ID 14, change it accordingly

    If someone with some development experience cleans this horror code up, I would be very happy. Still I’m proud I figured this out at all. 😉 Best case would be an updated plugin of course. 😉

Viewing 1 replies (of 1 total)
  • The topic ‘Ratings only for posts in certain category?’ is closed to new replies.