ACF关系字段由用户提供

时间:2016-08-29 13:48:59

标签: php wordpress advanced-custom-fields

尝试查询帖子是当前用户在用户关系字段中设置的。认为这很容易,但我完全陷入困境。 我试过这个:

<?php 
    $user = new WP_User(get_current_user_id());
    $posts = get_field('consultora', 'user_'.$user->ID);
    if( $posts ): 
?>
    <div class="assistente-foto">
        <?php foreach( $posts as $post):?>
        <?php setup_postdata($post); ?>

            <?php echo the_post_thumbnail();?>
            <p><strong><?php echo get_the_title(); ?></strong></p>
            <p>t. <?php the_field('telefone'); ?></p>
            <p>e. <?php the_field('email'); ?></p>
        <?php endforeach; ?>
    </div>
    <?php wp_reset_postdata();?>
    <?php endif; ?>

caption

0 个答案:

没有答案
相关问题