簡體   English   中英

我如何拉帖子和頁面

[英]how do I pull post and page

我在網站上啟用了頁面類別,並且試圖同時提取頁面和帖子。 我怎樣才能做到這一點? 如果我刪除'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>
'post_type' => array ('post', 'page')

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM