A menu for each page

Asked

Viewed 4,196 times

0

Problem:

The side menu appears on all pages. I wish I could use a different side menu for each page.

I know this has to do with the Wordpress theme. I’m kind of novice with Wordpress. I’m using a standard theme of those that comes already installed.

Question:

Would it be possible for me to do what I said? Put a different side menu on each page? If yes they could give me links or small information of how it should be done?

1 answer

1


It is possible, but in order to help first I need to know what this side menu is and how it is being called. How is the side of your site called? Usually there is a file called sidebar.php in the theme that is responsible for the presentation of the information on the side, if this is the case you can use the functions is_*(); Wordpress to check which page is being accessed and call the correct menu, example:

If you want a menu for the home and another for all internal pages:

if( is_home() ){
     // código do menu da home
}
else{
     // código do menu das internas
}

If you want a menu for the home, another for all internal and a different one for the contact page, does so:

if( is_home() ){
     // código do menu da home
}
else if( is_page( 'contato' ) ){
     // código do menu da página de contato
}
else{
     // código do menu de todas as outras páginas
}

You realize it’s quite relative?

  • Thanks friend, I had to go away for a few days so I still could not test many things. Tomorrow I must have some time to play a little...

  • I have the main menu at the top of the page with 7 main links. Each main link of this must have a different menu on the sidebar inside the page. I did all the menus on those pages. I put the menu that should appear on page 1 on the sidebar, when I will put the menu that should appear on page 2 the menu on page 1 disappears to appear on page 2 and this menu appears on all pages. Sorry but I’m new in wordpress, need to make a different template for each page? So far what I managed to do was different widgets areas.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.