前面咱們講到wordpress如何調用指定page頁面內容,如今再用另外的方法來調試一下,能夠直接在single.php模板使用,一樣能夠調用多id,隨ytkah一塊兒來看看php
<?php $args = array( 'include' => '673,23',//調用指定id,能夠多id 'post_type' => 'page', 'post_status' => 'publish' ); $pages = get_pages($args); foreach ( $pages as $post ) : setup_postdata( $post ); ?> <a href="<?php the_permalink(); ?>"><?php the_title(); ?></a> <?php endforeach; wp_reset_postdata(); ?>
詳細的參數html
<?php $args = array( 'posts_per_page' => 5, 'offset' => 0, 'cat' => '', 'category_name' => '', 'orderby' => 'date', 'order' => 'DESC', 'include' => '', 'exclude' => '', 'meta_key' => '', 'meta_value' => '', 'post_type' => 'post', 'post_mime_type' => '', 'post_parent' => '', 'author' => '', 'author_name' => '', 'post_status' => 'publish', 'suppress_filters' => true, 'fields' => '', ); $posts_array = get_posts( $args ); ?>
參考資料:https://codex.wordpress.org/Function_Reference/get_postswordpress