Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I've my website with homepage link set to http://www.mysite.com.

I've also many pages with subpages, and in that subpages i've already a link in the content that returns to the top level parent page.

Is it also possible to set this link in the nav menu overwriting my default home link?

Thanks,

Stefano

share|improve this question

2 Answers 2

You could make it with your theme with the hook wp_nav_menu_items :

add_filter('wp_nav_menu_items', 'wpse_104145_custom_home_link', 10, 2);
function wpse_104145_custom_home_link($items, $args) {

if( $args->theme_location == 'primary' )
    global $post;
    if($post->post_parent) {
    $permalink = get_permalink($post->post_parent);
    $homeLink = '<li id="home_link"><a href="' . $permalink . '">'.get_the_title($post->post_parent).'</a></li>';
    return $homeLink . $items;
    } else {
    return $items;
    }
}
share|improve this answer

You can put in Custom links from the wordpress menu dashboard.

share|improve this answer
    
But it won't be always the same link. For example: PAGE 1 -> SUBPAGE 1 (link to PAGE 1) --> SUBPAGE 2 (link to PAGE 1). PAGE 2 -> SUBPAGE 1 (link to PAGE 2) etc... –  Pepozzo Jun 25 '13 at 9:15
    
Then do see the documentation for Menu Walker. codex.wordpress.org/Function_Reference/… Using this you can set your conditions accordingly –  soden Jun 25 '13 at 9:17

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.