Friday, 12 October 2012

How to use more than one navigation in wordpress?

In the backend of wordpress, Goto Appearance->Menus and add your custom menus for primary navigation and save it.

This is only for primary navigaton. Then how to create another navigation? Its pretty simple!. Click the '+' sign tab near the primary navigation on top. Then in the Menu Name enter the new name of the navigation in the text box and click Create  Menu.

Voila! New navigation is created. Now you can add your custom menus to that navigation. But in the front end it shows only primary navigation.
Where is the navigation which I created now ? Don't freak out! We have to call the navigation in our theme file at the place we are displaying..




Open your wordpress wp-content\themes\header.php and find the php function wp_nav_menu();. This is where your navigation displays in your site.

Now you need to display another navigation in your site. So just copy that navigation code(wp_nav_menu()--totally) and paste where You need another navigation. Then go to your admin backend of Appearance->Menus again and inspect Theme locations select box in your firebug or whatever.Clearly shown in image!!

You'll find the navigation created by us in the option like this
<option value="5">secondary navigation</option>

Note that value of our navigation and goto code where we left off. Now paste that value inside that wp_nav_menu() function with 'menu' as a key like this:
<?php wp_nav_menu( array( 'theme_location' => 'primary','menu' => '5' ) ); ?>
Here 5 is the value we are passing to display that navigation.

That It! Save the file and check the site.


Thursday, 4 October 2012

How to add review star ratings to google search results for your post?

This question was asked millions of times already, so I decided to put up an article and answer this once and for all.
 There are several ways to include ratings in reviews.The most common way is to include the rating written out as a number directly in the HTML, like this microformats example:

Rating: <span class="rating">4.5</span>

Also you can refer this link by Google which gives detailed information
on this.
But I'll show you the easiest way to achieve this. Just include the below
code anywhere inside your post or page to display rating for review.

<div>
   <span itemscope="itemscope" itemtype="http://data-vocabulary.org/Review">
   <span itemprop="itemreviewed">How to Use Ajax in Magento?</span>
   Rating: <span itemprop="rating">5</span> out of 5
   <span itemprop="reviewer">Vignesh M</span></span>
</div>

Leave the first <span> as it is. In the second <span> tag, You'll find
<span itemprop="itemreviewed">How to Use Ajax in Magento?</span>

It is used to say what we are reviewing or name of the post or product.
In the third line(Which is really important for displaying rating star),

 Rating: <span itemprop="rating">5</span> out of 5

Change the 5 inside the <span itemprop="rating"> to corresponding rating of
the review. Then in the next line you'll find,

<span itemprop="reviewer">Vignesh M</span></span>

It is essential to display ratings by specifying the name of the reviewer.
Then save the post and test the link with Google's Structured Data Testing Tool

Thats It!!