2011-02-07 7 views
1

私は3つのIDを持っている場合などのget_pagesでページIDを配列で取得するには?

$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); 

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

がどのように私はget_pagesは私と一緒に、これらのページのIDを持つページに関するすべての情報を取得するために機能を設定することができますように、その与えO/P

おかげで助けてください

答えて

0

参照: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); 
+0

私は – rajeshrt

+0

はpage_idの "たtext_string" です... get_page機能にページIDの配列を挿入することができますか? – Jason

+0

いいえ私は私のansを持っています – rajeshrt

0

これを試してみてください、あなたがページのすべてのコンテンツを取得しているため、過去であり、それは非常に役に立った:これの

$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

関連する問題