0

我在我的网站上启用了页面类别,我正在尝试同时提取页面和帖子。我怎样才能做到这一点?如果我取出 '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>
4

1 回答 1

0
'post_type' => array ('post', 'page')
于 2013-07-05T13:25:10.067 回答