显示多种页面类型的结果

时间:2013-12-28 作者:aled2305

首先,很抱歉我之前的帖子,它太让人困惑了,我在1中问了3个问题。。。

好的,下面的代码是页面类型的所有页面

page_library_html_content.php
现在我想添加到这个代码中,让它显示所有页面类型的页面

page_library_css_content.php
我也是。因此,我将获得这两种页面类型的所有页面。

Code

<?php
$product_pages_args = array(
    \'meta_key\' => \'_wp_page_template\',
    \'meta_value\' => \'page_library_html_content.php\',
    \'hierarchical\' => \'0\',
);
$product_pages = get_pages( $product_pages_args );
?>

<?php
foreach ( $product_pages as $product_page ) {
    $author_id =  get_post_field(\'post_author\', $product_page->ID );
    $author_details = get_user_by( \'id\', $author_id );
    $author_name = $author_details->first_name . \' \' . $author_details->last_name;  

    echo \'<div id="posts" class="flex_100"><div class="posts_bar"></div>\';
    echo \'<div id="library_title"><a href="\' . get_permalink( $product_page->ID ) . \'">\' . $product_page->post_title  . \'</a></div>\';
    echo \'<div class="library-content">\' . get_post_field(\'post_content\', $product_page->ID ) . \'</div>\';
     echo \'<div class="library-author">Tutorial Instructor:  \' . $author_name . \'</div>\';
    echo \'<div class="library-author-av">\' . get_avatar( $author_id , 32 ) . \'</div></div>\';;

}
?>

1 个回复
SO网友:Robin Westerlundh

您应该使用“meta\\u query”,它是一个数组数组

$product_pages_args = array(
    \'meta_query\' => array(
      array(
       \'key\' => \'_wp_page_template\',
       \'value\' => array(\'page_library_html_content.php\',page_library_css_content.php\') ,
       \'compare\' => \'IN\'
    ), 
    )
)

结束