Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    New to the CF scene
    Join Date
    Apr 2007
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Wordpress/PHP troubles

    I am working in Wordpress, and I am a php newbie. I have a sidebar that changes depending on the page I'm on. If the parent page is Fruit and Oranges and Apples are subpages, then the sidebar will show:
    Fruit
    -Apples
    -Oranges

    But if the Parent Page doesnt have any children, a blank box shows up. I was wondering if there was a way to not show the "empty box" when the page has no children? I think it needs some sort of loop, but as I said before I'm a newbie, still learning all this. Thanks for the help here. I really want to learn more about PHP, and I feel this is a good example. For reference, I am using it on http://www.pokersyndicate.com


    Code:
    <li class="sidebox">
    
    <?php /* Creates a menu for pages beneath the level of the current page */
    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;
    
    if ($wpdb->get_results("SELECT * FROM $wpdb->posts WHERE post_parent = '$parent_id' AND post_status != 'attachment'")) { ?>
    
    <div class="sb-pagemenu"><h2><?php echo $parent_title; ?> Subpages</h2>
    
    <ul><?php wp_list_pages('sort_column=menu_order&title_li=&child_of='. $parent_id); ?></ul>
    <?php if ($parent_id != $post->ID) { ?>
    -Back to <a>" ><?php echo $parent_title; ?></a>
    <?php } ?>
    </div>
    <?php } } ?>
    Last edited by zonetrap; 04-04-2007 at 07:32 PM.

  • #2
    New to the CF scene
    Join Date
    Apr 2007
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Any leads/direction I can go?

  • #3
    UE Antagonizer Fumigator's Avatar
    Join Date
    Dec 2005
    Location
    Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
    Posts
    7,691
    Thanks
    42
    Thanked 637 Times in 625 Posts
    The reason why no one has been of any help is because this is really a Wordpress issue, not a PHP issue. Have you tried the Wordpress help forums?

  • #4
    New to the CF scene
    Join Date
    Apr 2007
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Yes I have, no one has responded. I thought it would be more of a php issue?

  • #5
    Super Moderator JohnDubya's Avatar
    Join Date
    Nov 2006
    Location
    Missouri
    Posts
    634
    Thanks
    12
    Thanked 18 Times in 18 Posts
    Zone, it would be helpful for you to change the title of your post, so people can know what your post is about. If someone sees "Wordpress" in the title, and they know a lot about it, they will be more likely to click on it. Good luck!

  • #6
    New to the CF scene
    Join Date
    Apr 2007
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks mate, its been changed!


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •