I use a menu side-wide but I want to make some menu items nofollow on single post only. Can any one help me how to do it?
Updated: I used the below mentioned code and it worked perfectly. Because I am new to wordpress, so please tell me if anything is wrong in it. [sorry for bad english]
add_filter('walker_nav_menu_start_el', 'nofollow_menu_items', 1, 4);
function nofollow_menu_items($item_output, $item, $depth, $args) {
if( is_single( ) )
$nofollow = array(258,261,262); // Menu item id's (View page source and menu-item-123)
$location = ''; // Use 'primary' to only filter header menu in twentyten
$menu = ''; // Use menu names to filter by menu
if(
in_array($item->ID, $nofollow)
&& (!empty($location) && $args->theme_location == $location || empty($location))
&& (!empty($menu) && $args->menu == $menu || empty($menu))
) {
$item_output = str_replace('<a ', '<a rel="nofollow" ', $item_output);
}
return $item_output;
}