WordPress.org

Ready to get started?Download WordPress

Forums

Adding a Nav menu to all child pages (2 posts)

  1. LizzyBrooks
    Member
    Posted 3 years ago #

    Hello Forum,

    I am trying to add a navigation menu to all of the child pages in my Image Gallery section. I can get the menu to appear on the parent page using a conditional statement placed in the page.php file. I'm trying to call all the child pages (and, in fact, NOT the parent page) using the info in this post http://wordpress.org/support/topic/conditional-tags-and-parentchild-pages.

    I can't get the menu to appear on the child pages, though.

    Thanks so much for any help!!

    Here is the site link: http://fullcirclephoto.com/gallery/
    And, here is my code:

    <?php get_header() ?>

    <div id="container">
    <div id="content">

    <?php the_post() ?>

    <div id="post-<?php the_ID() ?>" class="<?php sandbox_post_class() ?>">
    <h2 class="entry-title"><?php the_title() ?></h2>

    <?php
    $page = $wp_query->post;
    $parent_name = $wpdb->get_var("SELECT post_name FROM $wpdb->posts WHERE ID = '$page->post_parent;'");
    ?>
    <?php if (is_page('Image Gallery')|| 'Image Gallery' == $parent_name ) { ?>

    <!-- * { margin:0; padding:0; html { background:#444; }

    table { margin:50px auto; width:630px; height:466px; background:#222; overflow:hidden; }

    div#menu { top:40px; left:0px; width:100%; background:transparent url(images/header_bg.gif) repeat-x 0 0; } div#copyright { display: none; } -->

    <div id="Gmenu">
    <ul class="Gmenu">

    <li class="GmenuLi"><span>North America</span>

    <div>

    </div>

    <li class="GmenuLi"><span>South America</span>

    <div>

    </div>

    <li class="GmenuLi"><span>Africa</span>

    <div>

    </div>

    <li class="GmenuLi"><span>Europe</span>

    <div>

    </div>

    <li class="last"><span>Asia</span>
    <div>

    </div>
    </div>

    <?php } else { ?>

    <div style="background:#ffffff" </div>

    <?php } ?>

    <div class="entry-content">

    <?php the_content() ?>

    <?php wp_link_pages('before=<div class="page-link">' . __( 'Pages:', 'sandbox' ) . '&after=</div>') ?>

    <?php edit_post_link( __( 'Edit', 'sandbox' ), '<span class="edit-link">', '</span>' ) ?>

    </div>

    </div><!-- .post -->
    </div><!-- #content -->
    </div><!-- #container -->

    <?php // get_sidebar() ?>
    <?php get_footer() ?>

  2. hennock
    Member
    Posted 3 years ago #

    Hi Lizzy,

    I tried using code from that thread and had no luck either. I found code that did work, though!

    If you want to call the parent AND child pages:

    (is_page(pageid) || $post->post_parent=="pageid")

    Example:

    <?php if (is_page('contact') || $post->post_parent=="2")) { ?>

    Or if you just want to call the only the child pages:

    ($post->post_parent=="pageid")

    Example:

    <?php if ($post->post_parent=="2")) { ?>

    Hope that helps!

Topic Closed

This topic has been closed to new replies.

About this Topic