首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何拉取帖子和页面

如何拉取帖子和页面
EN

Stack Overflow用户
提问于 2012-10-02 07:08:10
回答 1查看 35关注 0票数 0

我已经在我的网站上启用了页面类别,我正在尝试拉动页面和帖子。我该怎么做呢?如果我去掉'post_type‘=>’页面‘,它默认只发布帖子。

代码语言:javascript
复制
<ul class="list-item">   

                <?php
                // Set up the arguments for retrieving the pages
                $args = array(
                    'post_type' => 'page',
                    'numberposts' => -1,
                    'post_status' => null,
                // $post->ID gets the ID of the current page
                'category' => 126,
                    'order' => ASC,
                    'orderby' => title
                    );
                 $subpages = get_posts($args);
                 // Just another WordPress Loop
                 foreach($subpages as $post) :
                    setup_postdata($post);
                 ?>

                <li>
                    <a href="<?php the_permalink(); ?>">
                        <img src="<?php echo gangmei_get_the_post_thumbnail_url($post->ID, 'large'); ?>" alt="image" />
                        <span class="holder">
                            <h2><?php the_title(); ?></h2>
                            <span class="postmeta"><?php echo 'The post type is: '.get_post_type( $post->ID ); ?>, <?php the_date(); ?></span>
                            <span class="txt"><?php the_excerpt_rss(); ?></span>
                        </span>
                        <span class="mask-1">mask</span>
                        <span class="mask-2">mask</span>
                    </a>
                </li>



            <?php endforeach; ?> 
            </ul>
EN

回答 1

Stack Overflow用户

发布于 2013-07-05 21:25:10

代码语言:javascript
复制
'post_type' => array ('post', 'page')
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/12682362

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档