WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?



share|improve this question

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

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

Your Answer


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.