普通网友 2013-03-22 11:12
浏览 19

子页面及其特色图像不会在wordpress的父页面中拉出

For some reason in Genisis framework, wordpress the following code is not pulling up the child pages and its featured images

 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();

Thank you.

  • 写回答

1条回答 默认 最新

  • douyi6755 2013-09-21 14:43
    关注

    The error is in your get_results() arguments.

    First assign post->ID to a variable and then use it in get_results() like so:

    $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');    ?>
    

    Also I am not sure that you can use menu_order and 'page' the way you did, check the documentation how to get those.

    评论

报告相同问题?

悬赏问题

  • ¥50 如何用脚本实现输入法的热键设置
  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100
  • ¥15 关于#hadoop#的问题
  • ¥15 (标签-Python|关键词-socket)