New Posts
Live Radio
Welcome guest, is this your first visit?
  • Login:
Pokerview.com Affiliate Program
+ Reply to Thread
Results 1 to 8 of 8
  1. #1
    Member
    My Status
     

    Add as a friend
    Join Date
    Jan 2009
    Location
    United States of America
    Posts
    21
    Feedback Score
    0

    Default Little Menu Help Please

    Ok - Here is what I thought I could simply "knock out" and move and now I've thought myself into a knot!

    I have one menu in sidebar - I want the pages to be listed there in a menu.

    Code:
    <?php wp_list_pages('title_li='); ?>
    No biggie but I DO NOT want the child menus to show on home page - just when I click on the child.

    So I did this:

    Code:
    <?php
    if ($post->post_parent) {
     $parent = $post->post_parent;
    } else {
     $parent = $post->ID;
    }
    wp_list_pages("title_li=&child_of=$parent");
    ?>
    Works! Sorta .

    When I go to a page all the child pages show up BUT I get no pages at all on the home page!

    Please, while I have one or two hairs left, tell me what I have missed.
    If your success is not on your own terms, if it looks good to the world but does not feel good in your heart, it is not success at all.

  2. #2
    Tom
    Tom is offline
    Senior Member
    My Status
     

    Add as a friend
    Join Date
    Nov 2008
    Location
    H-Town
    Posts
    579
    Blog Entries
    4
    Feedback Score
    5 (100%)

    Default

    To only display the top level pages use this:

    Code:
    <?php wp_list_pages('depth=1&title_li='); ?>
    Premium Wordpress Themes for Poker, Casino, and other Gambling Affiliates
    View the themes here <----Click Here

  3. #3
    Member
    My Status
     

    Add as a friend
    Join Date
    Jan 2009
    Location
    United States of America
    Posts
    21
    Feedback Score
    0

    Default

    Quote Originally Posted by Tom View Post
    To only display the top level pages use this:

    Code:
    <?php wp_list_pages('depth=1&title_li='); ?>

    But this is every page. I only want this on home page.

    All the other pages I want the child menus to display.
    If your success is not on your own terms, if it looks good to the world but does not feel good in your heart, it is not success at all.

  4. #4
    Let's Eat A Goddamn Snack
    My Status
     

    Add as a friend
    Join Date
    Nov 2008
    Location
    Cayman Islands
    Posts
    204
    Feedback Score
    0

    Default

    Okay, this isn't exactly what you asked for, but it works for a site of mine. To be fair, some of this code was stolen from the K2 theme (although I adopted and modified it).

    For index.php, use a regular sidebar.php include.

    For page.php, use include a page called sidebarpage.php and put this code in it.

    PHP Code:
    <?php
    global $notfound;
    if (
    is_page() and ($notfound != '1')) {
      
    $current_page $post->ID;
      while(
    $current_page) {
        
    $page_query $wpdb->get_row("SELECT ID, post_title, post_status, post_parent FROM $wpdb->posts WHERE ID = '$current_page'");
        
    $current_page $page_query->post_parent;
      }
      
    $parent_id $page_query->ID;
      
    $parent_title $page_query->post_title;
      
      
    $query "SELECT * FROM $wpdb->posts WHERE post_parent = '$parent_id' AND post_type != 'attachment' AND post_type = 'page'";
      
      if (
    $wpdb->get_results($query)) {
      
    ?>
      
        <li>
          <h2 class="sidebartitle"><?php echo $parent_title?></h2>
          <ul class="list-page">
          <?php wp_list_pages('sort_column=menu_order&title_li=&child_of='$parent_id); ?>
          </ul>
        </li>

    <?php } } ?>
    It might not be the most elegant solution, but it works great. Depending on the complexity of your site, you might be able to avoid the two sidebars with another if/else added to what I just posted.

  5. #5
    Member
    My Status
     

    Add as a friend
    Join Date
    Jan 2009
    Location
    United States of America
    Posts
    21
    Feedback Score
    0

    Default

    Thanks for help Nat - Afraid I am getting same issues I have with all my solutions so far.

    Works great except on the main static page - will not show any pages at all in the menu.

    Code:
    <?php wp_list_pages('title_li='); ?>
    List all like it is suppose to (unfortunately even the sub menus).

    I am working off a local server trying to get it all working before I convert my site over so cannot show a sample.

    This is last hang up but turned out to be a big one.
    If your success is not on your own terms, if it looks good to the world but does not feel good in your heart, it is not success at all.

  6. #6
    Let's Eat A Goddamn Snack
    My Status
     

    Add as a friend
    Join Date
    Nov 2008
    Location
    Cayman Islands
    Posts
    204
    Feedback Score
    0

    Default

    Did you create two sidebars like I stated? What do you have in the other one? (ie, the one I did not provide the code for)

  7. #7
    Member
    My Status
     

    Add as a friend
    Join Date
    Jan 2009
    Location
    United States of America
    Posts
    21
    Feedback Score
    0

    Default

    I think I figured it out after posting. Looks better than anything I had going!

    Thanks again for your time and code.

    I didn't think when I started this little quest it would be so hard
    If your success is not on your own terms, if it looks good to the world but does not feel good in your heart, it is not success at all.

  8. #8
    Let's Eat A Goddamn Snack
    My Status
     

    Add as a friend
    Join Date
    Nov 2008
    Location
    Cayman Islands
    Posts
    204
    Feedback Score
    0

    Default

    Sure, glad you figured it out.


 

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

     

Similar Threads

  1. Sub Menu Problem
    By MPC in forum Wordpress - Web Design - Coding - Technical
    Replies: 0
    Last Post: 03-10-2010, 07:58 PM
  2. menu Link Targets
    By Lenny in forum Wordpress - Web Design - Coding - Technical
    Replies: 1
    Last Post: 12-11-2009, 10:00 AM
  3. WordPress Menu Creators
    By Barry O'Callaghan in forum Wordpress - Web Design - Coding - Technical
    Replies: 6
    Last Post: 11-05-2009, 05:57 AM
  4. PHP inserted menu: less internal links?
    By FirstTimePokerPlayer in forum Poker SEO Forum
    Replies: 4
    Last Post: 09-10-2009, 06:02 AM
  5. Menu too wide in Firefox 3
    By JamesLomas in forum Wordpress - Web Design - Coding - Technical
    Replies: 3
    Last Post: 03-04-2009, 10:37 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
Powered by vBulletin® Version 4.1.5
Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.
SEO by vBSEO 3.6.0
Affiliate Program Consultant