Как получить идентификатор страницы в массиве в get_pages? - PullRequest
1 голос
/ 07 февраля 2011

если у меня есть 3 идентификатора, например

$page1 = get_option('home_page_field');
$page2 = get_option('home_page_field1');
$page3 = get_option('home_page_field2');
$page4 = get_option('home_page_field3');
$arrData = array( $page1, $page2 , $page3 );

, что дает o / p как

Array ( [0] => Array ( [text_string] => 2 ) [1] => Array ( [text_string] => 499 ) [2] => Array ( [text_string] => 869 ) )

как я могу установить функцию get_pages, чтобы получить всю информацию о страницах с этими страницамиидентификаторы со мной

Пожалуйста, помогите Спасибо

Ответы [ 2 ]

0 голосов
/ 13 февраля 2017

Я использовал это прошлое и нашел его весьма полезным, потому что вы получаете все содержимое страниц:

$mypages = get_pages( array( 'parent' => $post->ID ) );
// you could put any ID here, or any of the page identifiers in the get_pages function (https://codex.wordpress.org/Function_Reference/get_pages)

foreach( $mypages as $page ) {      
    $content = $page->post_content;
    if ( ! $content ) // Check for empty page
        continue;

   $content = apply_filters( 'the_content', $content );
?>
//This allows you to access any of the content on these pages, like this:

<div style="background-image: url('<?php echo get_the_post_thumbnail_url( $page, 'post-thumbnail' ) ?>'); ">"
    <p style="color: white; text-transform: uppercase;"><?php echo $page->post_title; ?></p>
</div>

Различные варианты этого очень помогли мне в прошлом - дайте мне знать, если он делает то, что вам нужно!

-Alyssa

0 голосов
/ 07 февраля 2011

См .: http://codex.wordpress.org/Function_Reference/get_page

<?php print_r(get_page( $page_id )) ?>

Попробуйте это

$pages = array();
foreach($arrData as $item){
   $pages[(int)$item['text_string']] = get_page((int)$item['text_string']);
}
print_r($pages);
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...