Support » Themes and Templates » Nofollow specific links in NavBar?

  • I’m trying to nofollow specific links in my navbar.

    The code in my header.php looks like this:

    <div id="navmenu-wrapper">
                            <?php themefunction_page_menu(); ?>

    The code for themefunction_page_menu in my theme fuctions.php looks like this:

    function themefunction_alter_page_menu($string) {
    	$string = themefunction_alter_list_pages($string);
    	$pattern = array('/<div[^<>]*>/','/<\/div[^<>]*>/');
    	$replace = array('','');
    	$string = preg_replace($pattern,$replace,$string);
    	return $string;

    Full theme functions file

    In the past I used the following code to solve this problem, but the code was different and I’m not sure how I can implement it into my theme. Any suggestions would be greatly appreciated!

    Old code:

    // Add post ID to nofollow separated by comma
    $nofollow_posts = array(1, 2);
    if ( in_array( $page->ID, $nofollow_posts ) )
    	$nofollow = ' rel="nofollow"';
    	$nofollow = '';
    $output .= $indent . '<li class="' . $css_class . '"><a '. $nofollow . 'href="' . get_page_link($page->ID) . '" title="' . attribute_escape(apply_filters('the_title', $page->post_title)) . '"><span>' . apply_filters('the_title', $page->post_title) . '</span></a></li>';

    I would then change the array(1, 2); to the post i’ds I wanted to nofollow.

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘Nofollow specific links in NavBar?’ is closed to new replies.