[英]ACF - page selector get custom field as well
我正在使用“高级自定义字段”,并且选择了“页面选择器”,可以选择页面。
在前端,我可以对其进行编码,以使我选择的页面位于带有标题和页面链接的主页上,但是我也试图在该页面中浏览自定义字段。
这是我到目前为止的代码;
<?php if( have_rows('page_selector') ):
$i=1;
$count = (count($my_fields['value']));
?>
<?php while( have_rows('page_selector') ): the_row();
// vars
$page = get_sub_field('page');
?>
<div class="lg-col-6 md-col-6">
<div class="sub_service">
<?php
// vars
$post_id = get_sub_field('page', false, false);
// check
if( $post_id ): ?>
<a href="<?php echo get_the_permalink($post_id); ?>"><h2><?php echo get_the_title($post_id); ?></h2></a>
<?php endif; ?>
//This is the custom field
<?php get_sub_field('description'); ?>
</div>
</div>
<?php
$i++;
endwhile; ?>
<?php endif; ?>
<?php wp_reset_query(); ?>
如果没有道歉,请事先道歉,如果会造成混淆,请尝试进一步解释。
谢谢
您发布问题,然后答案就来了...
<?php the_field('description', $post_id); ?>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.