我有一个变量,我想添加doc-它,所以它读出doc- $ user_role这样的高级自定义字段在wordpress中。PHP高级自定义字段中继器字段
我知道如何与回声做到这一点发现很难以这种格式一些帮助,请:)
<?php
$user_roles = $current_user->roles;
$user_role = array_shift($user_roles);
if(get_field('doc-$user_role')): ?>
<ul>
<?php while(has_sub_field('doc-$user_role')): ?>
<li>
<h3><?php the_sub_field('doc_name'); ?></h3>
<p><?php the_sub_field('doc_description'); ?></p>
<a href="<?php the_sub_field('download_doc'); ?>" target="_blank"><img src="<?php bloginfo('template_directory'); ?>/images/download.png" alt="download_button"></a>
</li>
<?php endwhile; ?>
</ul>
<?php endif; ?>
我不明白你的问题是如何工作的完整说明。你能详细说明一下吗? – str 2013-04-23 12:45:08
这是错误的,如果(get_field('doc- $ user_role')):?> 它是如何被写入?我有一个用户角色名称,并希望添加它的文档。 – mariovass 2013-04-23 12:47:00