2013-03-22 58 views
0

出於某種原因,在Genisis框架,WordPress的下面的代碼不拉子頁面和它的特色照片兒童網頁和他們的特色照片父頁面不拉在WordPress

add_filter('body_class', 'add_body_class'); 
function add_body_class($classes) { 
    $classes[] = 'portfolio'; 
return $classes; 
} 

add_filter('genesis_pre_get_option_site_layout', '__genesis_return_full_width_content'  ); // Force Full-Width Layout 
remove_action('genesis_before_loop', 'genesis_do_breadcrumbs'); // Removes  breadcrumbs 
remove_action('genesis_post_title','genesis_do_post_title'); // Removes post title 
remove_action('genesis_post_content', 'genesis_do_post_content'); // Removes content 
add_action('genesis_post_content', 'child_do_content'); // Adds your custom page code/content 

    // Do Custom Content 
function child_do_content() { ?> 

<?php global $wpdb; ?> 
<?php the_content(); ?> 
<?php 
$child_pages = $wpdb->get_results("SELECT * FROM $wpdb->posts WHERE post_parent = ".$post->ID." AND post_type = 'page' ORDER BY menu_order", 'OBJECT'); ?> 
<?php if ($child_pages) : foreach ($child_pages as $pageChild) : setup_postdata($pageChild); ?> 
<?php echo get_the_post_thumbnail($pageChild->ID, 'thumbnail'); ?> 
<a href="<?php echo get_permalink($pageChild->ID); ?>" title="<?php echo $pageChild->post_title; ?>"><?php echo $pageChild->post_title; ?></a> 
<?php endforeach; endif; ?> 

<?php }genesis(); 

謝謝。

回答

0

錯誤發生在您的get_results()參數中。

首先分配post->ID給一個變量,然後用它在get_results()像這樣:

$parent = $post->ID; 
$child_pages = $wpdb->get_results("SELECT * FROM $wpdb->posts WHERE post_parent = $parent AND post_type = 'page' ORDER BY menu_order", 'OBJECT'); ?> 

而且我不知道,你可以使用menu_order'page'你做的方式,檢查documentation如何讓這些。

相關問題