[英]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.