WordPress.org

Forums

Using index.php as a parent page (why can't do I do this?) (4 posts)

  1. NeilC
    Member
    Posted 7 years ago #

    Check out http://test.dotneil.com and you'll see a skeleton outline for a site that I'm setting up. It has a two tier navigation; main tabs and sub-tabs. The sub-tabs only show when the respective parent tab is selected. However, I want to keep my design consistent, which that means that I also want to show sub-tabs on the blog/index.php/home.php (or whatever you'd like to call it). But, WordPress doesn't give me the option of using the 'automatcially' created blog page as parent page. I realise that this is because this 'page' isn't really a page in the traditional WordPress sense, but I'd still like to use it as a parent with it's own sub-nav.

    I've done my best to search round for plugins or other forum posts with the same issue etc, but no luck. I'm quite suprised because I would've thought that a consistent, two tier navigation would've been used by at least a few WordPress users, in which case someone else has probably worked out a way around this problem.

    Is there a way for me to force WP in to using the main blog page as a parent page for child pages? Or, do I need to create my own front page template which acts in the same manner, and therefore bypassing the use of the index.php/home.php entirely?

    Also, does anyone know why the commentlink disappears on single pages? I need to work around this one too!

  2. volfro
    Member
    Posted 7 years ago #

    It sounds like you'd best be served by customizing either your index.php or creating a template for your pages. If you create a page template that uses your navigation/subnavigation, you can put the Loop in that template as well; in fact, with query_posts and the customization options in the administration panels, you can create a page for blog posts that's entirely separate from index.php, effectively bypassing it, as you mentioned.

    So, yeah. I think the easiest thing to do would be to create a Page template that does what you want it to do, but I could be wrong. I'm no guru.

  3. NeilC
    Member
    Posted 7 years ago #

    I ended-up using the index template, creating pages, and hard coding a sub-nav for those pages into the index.

    Looks like this;

    <?php if(is_home() || is_search() || is_archive() || is_single() || is_page('Archives') || is_page('Popular')) { ?>

      <li class="page_item<?php if(is_home()){echo(' current_page_item');} ?>">Latest
      <li class="page_item<?php if(is_page('Archives')){echo(' current_page_item');} ?>">Archives
      <li class="page_item<?php if(is_page('Popular')){echo(' current_page_item');} ?>">Popular

    <?php } else {
    $children = ($post->post_parent) ? wp_list_pages('title_li=&child_of='.$post->post_parent.'&echo=0') : wp_list_pages('title_li=&child_of='.$post->ID.'&echo=0');
    if($children) { echo('

      '.$children.'
    '); }
    } ?>

  4. volfro
    Member
    Posted 7 years ago #

    That's exactly what I did on my site.

Topic Closed

This topic has been closed to new replies.

About this Topic