...

View Full Version : Wordpress/PHP troubles



zonetrap
04-03-2007, 08:39 PM
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



<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 } } ?>

zonetrap
04-04-2007, 12:52 AM
Any leads/direction I can go?

Fumigator
04-04-2007, 06:59 AM
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?

zonetrap
04-04-2007, 08:02 PM
Yes I have, no one has responded. I thought it would be more of a php issue?

JohnDubya
04-04-2007, 08:18 PM
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! :thumbsup:

zonetrap
04-04-2007, 08:32 PM
Thanks mate, its been changed! :thumbsup:



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum