douben1891 2011-07-26 13:37
浏览 10
已采纳

wordpress wp_list_pages帮助

In my wordpress enviroment, I have a number of pages, and I also have a custom post type called casestudy. I have setup a page-clients.php that has some of it's own content on, I then use the query_posts() function to pull in all the posts with the post type casestudy.

When viewing a single case study I wanting to show a nav, this nav needs to contain the links to pages, clients, and case study and underneath case studies I want to add all the posts that are of the custom post type 'casestudy' so far I have following,

<?php wp_list_pages(array('include' => '154, 136', 'title_li' => '', 'sort_column' => 'ID', 'sort_order' => 'DESC', 'depth' => '1')); ?>

How can I lists all the casestudy posts also, can it be done with wp_list_pages()

  • 写回答

1条回答 默认 最新

  • douyan2470 2011-07-26 20:31
    关注

    From the Wordpress documentation:

    $args = array( 'post_type' => 'product', 'posts_per_page' => 10 );
    $loop = new WP_Query( $args );
    while ( $loop->have_posts() ) : $loop->the_post();
        the_title();
        echo '<div class="entry-content">';
        the_content();
        echo '</div>';
    endwhile;
    

    You could have something like:

    $args = array( 'post_type' => 'casestudy');
    $case_studies = new WP_Query( $args );
    var_dump($case_studies);
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 求解 yolo算法问题
  • ¥15 虚拟机打包apk出现错误
  • ¥30 最小化遗憾贪心算法上界
  • ¥15 用visual studi code完成html页面
  • ¥15 聚类分析或者python进行数据分析
  • ¥15 逻辑谓词和消解原理的运用
  • ¥15 三菱伺服电机按启动按钮有使能但不动作
  • ¥15 js,页面2返回页面1时定位进入的设备
  • ¥50 导入文件到网吧的电脑并且在重启之后不会被恢复
  • ¥15 (希望可以解决问题)ma和mb文件无法正常打开,打开后是空白,但是有正常内存占用,但可以在打开Maya应用程序后打开场景ma和mb格式。