0

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

0

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

  • 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 – sodhancha Jun 25 '13 at 9:17
0

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;
    }
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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