Hello people! I’ve been playing with Wordpress for 2 weeks now and today I tried to make my very own div id that I can use in page templates. I obviously stumbled into some issues. Here’s what I did.
First I added this code for a new “div id” in the index. It’s to list childpages in the parent page:
<div id="childpages">
<?php if ($post?>post_parent == 0) {
$children = wp_list_pages("title_li=&child_of=".$post->ID."&echo=0");
$parentpage = $wpdb->get_row("SELECT ID, post_title, post_name FROM $wpdb->posts WHERE ID = '".$post->ID."'");
}
if ($post->post_parent != 0) {
$next_post_parent = $post->post_parent;
while ($next_post_parent != 0) {
$children = wp_list_pages("title_li=&child_of=".$next_post_parent."&echo=0");
$parentpage = $wpdb->get_row("SELECT ID, post_title, post_parent, post_name FROM $wpdb->posts WHERE ID = '".$next_post_parent."'");
$next_post_parent = $parentpage->post_parent;
}
}
?>
<?php if ($children) { ?>
<ul>
<li><h2><a href="<?php echo get_permalink($parentpage->ID); ?>"><?php echo $parentpage?>post_title; ?></a></h2>
<ul>
<?php echo $children; ?>
</ul>
</li>
</ul>
<?php } ?>
</div>
Next I headed to the css and added this in the layout section:
#childpages {
float:left;
width:270px;
And finally I duplicated the page.php, gave it a page template name added to the bottom, <?php get_childpages(); ?> And chose the template for my “about” page.
And the result is this http://www.graphictask.com/?page_id=2
Fatal error: Call to undefined function get_childpages() in /home/requestg/public_html/graphictask/wp-content/themes/bigfeature/childpage Template.php on line 53
The child pages were supposed to appear in the right there..
Am I doing something TERRIBLY wrong? I really want to learn WP!
