我如何拉帖子和页面

时间:2012-10-01 23:08:10

标签: php wordpress posts

我的网站上启用了网页类别,而我正试图同时提取网页和帖子。我怎样才能做到这一点?如果我拿出'post_type'=> 'page'默认只发布帖子。

<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>

1 个答案:

答案 0 :(得分:0)

'post_type' => array ('post', 'page')