[英]Get custom field (acf) from array of pages - wordpress
I have this function for getting pages with a certain template: 我具有用于获取具有特定模板的页面的此功能:
$parteneri = get_pages(array(
'post_type' => 'page',
'meta_key' => '_wp_page_template',
'meta_value' => 'template_parteneri.php',
'meta_compare' => '!='
));
This returns an array. 这将返回一个数组。 How would I be able to access some custom fields (advanced custom fields) on those pages returned?
在返回的那些页面上,我将如何访问某些自定义字段(高级自定义字段)?
I imagine you would have to loop through pages and use 我想您将不得不遍历页面并使用
get_post_meta( $post_id, $key, $single );
for each of your custom fields. 您的每个自定义字段。 I don't know any other solution at this moment.
目前我不知道其他解决方案。
I found out, I made a Query with that array. 我发现,我对该数组进行了查询。 I just added:
我刚刚添加:
$queryObject = new WP_Query($pages); $ queryObject =新的WP_Query($ pages); ?>
?>
<?php if ( $queryObject->have_posts() )
while (
$queryObject->have_posts() ) :
$queryObject->the_post();
?>
<p><?php the_field('continut_pagina'); ?></p>
<?php endwhile; ?>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.