【问题标题】:wordpress wp_list_pages helpwordpress wp_list_pages 帮助
【发布时间】:2011-10-13 10:28:48
【问题描述】:

在我的 wordpress 环境中,我有许多页面,并且我还有一个名为 casetudy 的自定义帖子类型。我已经设置了一个 page-clients.php,其中包含一些自己的内容,然后我使用query_posts() 函数来拉入所有帖子类型为案例研究的帖子。

查看单个案例研究时,我想显示一个导航,此导航需要包含指向页面、客户和案例研究的链接,并且在案例研究下方我想添加所有属于自定义帖子类型的帖子'到目前为止,我有以下案例研究,

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

我怎样才能列出所有的casestudy帖子,可以用wp_list_pages()完成

【问题讨论】:

    标签: php wordpress custom-post-type


    【解决方案1】:

    来自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;
    

    你可以有类似的东西:

    $args = array( 'post_type' => 'casestudy');
    $case_studies = new WP_Query( $args );
    var_dump($case_studies);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-06-05
      • 2016-01-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多