WordPress.org

Ready to get started?Download WordPress

Forums

Sidebar menu displaying only on one page, how to ? (2 posts)

  1. Akasashasha
    Member
    Posted 1 year ago #

    Dears,

    everything's in the title.
    I want to have different sidebar custom menu for each page ... now if I put a sidebar menu it appear in all pages of my website
    I'm using the Esplanade theme and can't show my website at the moment cause working localy.

    thanx

  2. alby54
    Member
    Posted 1 year ago #

    I do not know Esplanade theme but I guess you could create different sidebar templates like sidebar-1.php sidebar-2.php ... and then edit your main template replacing the code
    <?php get_sidebar(); ?>
    with

    <?php get_sidebar( $name );
    if ( is_page( 'page-1' ) ) :
      get_sidebar('sidebar-1');
    elseif ( is_page( 'page-2' ) ) :
      get_sidebar('sidebar-2');
    else
      get_sidebar();
    endif
    ?>

    If you have subpages that share the same sidebar then you should use 'tree' + ID number

    if ( is_tree( 'xx' ) ) ://where xx is the parent page ID
      get_sidebar('sidebar-1');

Topic Closed

This topic has been closed to new replies.

About this Topic