<?php acf_snippet_get_link($selector, [$postId], [$args]);
acf_snippet_get_link($ selector,[$ postId],[$ args]);
?>
?>
code> pre>
Displays the snippet of a specific link field.
显示特定链接字段的代码段。 p>
<?php acf_snippet_the_link($selector, [$postId], [$args]);
acf_snippet_the_link($ selector,[$ postId],[$ args]);
?>
?>
code> pre>
Parameters
参数 strong>
$selector (string) (Required) ACF field name or ACF field key.
$ selector (字符串)(必需) em> ACF字段名称或ACF字段键。Based on ACF get_field function.
基于 ACF get_field函数。
$postId (integer|bool) (Optional) The post ID where the value is saved.
$ postId (integer | bool)(可选) em>保存值的帖子ID。Use true
for getting sub field.
使用 true code>获取子字段。Default value: false
(current post).
默认值: false code>(当前发布)。
$args (array) (Optional) Array of link output arguments.
$ args (array)(可选) em>链接输出参数的数组。Default value: null
.
默认值: null code>。
‘class’ (string) class
attribute of the anchor.
锚的“类” strong> (字符串) em> class code>属性。
‘id’ (string) id
attribute of the anchor.
锚的'id' strong> (字符串) em> id code>属性。
‘title’ (string) title
attribute text of the anchor.
锚的“标题” strong> (字符串) em> title code>属性文本。 p>Image
图片 h4>
Returns the snippet of a specific image field.
返回特定图像字段的摘要。 p>
<?php acf_snippet_get_image($selector, [$postId], [$args]);
acf_snippet_get_image($ selector,[$ postId],[$ args]);
?>
?>
code> pre>
Displays the snippet of a specific image field.
显示特定图像字段的代码段。 p>
<?php acf_snippet_the_image($selector, [$postId], [$args]);
acf_snippet_the_image($ selector,[$ postId],[$ args]);
?>
?>
code> pre>
Parameters
参数 strong>
$selector (string) (Required) ACF field name or ACF field key.
$ selector (字符串)(必需) em> ACF字段名称或ACF字段键。Based on ACF get_field function.
基于 ACF get_field函数。
$postId (integer|bool) (Optional) The post ID where the value is saved.
$ postId (integer | bool)(可选) em>保存值的帖子ID。Use true
for getting sub field.
使用 true code>获取子字段。Default value: false
(current post).
默认值: false code>(当前发布)。
$args (array) (Optional) Array of image output arguments.
$ args (array)(可选) em>图像输出参数的数组。Default value: null
.
默认值: null code>。
‘size’ (string) Image size to use.
“尺寸” strong> (字符串) em>要使用的图像尺寸。Accepts any valid image size.
接受任何有效的图像尺寸。
Default value is full
.
默认值为 full code>。
‘alt’ (string) alt
attribute of the image.
图像的'alt' strong> (字符串) em> alt code>属性。
‘id’ (string) id
attribute of the image.
图片的'id' strong> (字符串) em> id code>属性。
‘class’ (string) class
attribute of the image.
图像的“类” strong> (字符串) em> class code>属性。
‘title’ (string) title
attribute of the image.
图像的“标题” strong> (字符串) em> title code>属性。
‘srcset’ (bool) Use true
for retrieving image’s srcset
attribute.
“ srcset” strong> (布尔) em>使用 true code>检索图像的 srcset code>属性。Default value: false
.
默认值: false code>。
‘loading’ (string) loading
attribute of the image.
图像的“加载” strong> (字符串) em> 加载 code>属性。Default value: lazy
.
默认值: lazy code>。
‘link’ (bool|array) Array of attributes for anchor wrapped around the image.
“链接” strong> (布尔|数组) em>锚定在图片周围的属性数组。Default value: false
.
默认值: false code>。
‘href’ (string) href
attribute of the link.
链接的'href' strong> (字符串) em> href code>属性。
‘target’ (string) target
attribute of the link.
链接的“目标” strong> (字符串) em> target code>属性。
‘class’ (string) class
attribute of the link.
链接的“类” strong> (字符串) em> class code>属性。
‘id’ (string) id
attribute of the link.
链接的'id' strong> (字符串) em> id code>属性。
‘title’ (string) title
attribute of the link.
链接的“标题” strong> (字符串) em> title code>属性。 p>Repeater
中继器 h4>
Displays the snippet of a specific repeater field.
显示特定中继器字段的代码段。 p>
<?php acf_snippet_the_repeater($selector, [$postId], [$args]);
acf_snippet_the_repeater($ selector,[$ postId],[$ args]);
?>
?>
code> pre>
Parameters
参数 strong>
$selector (string) (Required) ACF field name or ACF field key.
$ selector (字符串)(必需) em> ACF字段名称或ACF字段键。Based on ACF get_field function.
基于 ACF get_field函数。
$postId (integer|bool) (Optional) The post ID where the value is saved.
$ postId (integer | bool)(可选) em>保存值的帖子ID。Default value: false
(current post).
默认值: false code>(当前发布)。
$args (array) (Optional) Array of repeater output arguments.
$ args (array)(可选) em>中继器输出参数的数组。Default value: null
.
默认值: null code>。
‘template’ (string|array) Template for items inside the loop.
“模板” strong> (字符串|数组) em>循环中项目的模板。 Arguments of get_template_part
function.
get_template_part code>函数的参数。In the template use standard get_sub_field function
.
在模板中,使用标准的 get_sub_field函数 code>。
‘wrap_before’ (string) Text (HTML) before repeater items while have rows.
“ wrap_before” strong> (字符串) em>在具有行的中继器项目之前的文本(HTML)。
‘wrap_after’ (string) Text (HTML) after repeater items while have rows
“ wrap_after” strong> (字符串) em>带有行的重复项目后的文本(HTML)
’empty_html’ (string) Text (HTML) in case there are no rows in repeater.
“ empty_html” strong> (字符串) em>文本(HTML),以防中继器中没有行。 p>Flexible content
灵活的内容 h4>
Displays the snippet of a specific flexible field.
显示特定弹性字段的代码段。 p>
<?php acf_snippet_the_flexible_content($selector, [$postId], [$args]);
acf_snippet_the_flexible_content($ selector,[$ postId],[$ args]);
?>
?>
code> pre>
Parameters
参数 strong>
$selector (string) (Required) ACF field name or ACF field key.
$ selector (字符串)(必需) em> ACF字段名称或ACF字段键。Based on ACF get_field function.
基于 ACF get_field函数。
$postId (integer|bool) (Optional) The post ID where the value is saved.
$ postId (integer | bool)(可选) em>保存值的帖子ID。Default value: false
(current post).
默认值: false code>(当前发布)。
$args (array) (Optional) Array of flexible content output arguments.
$ args (array)(可选) em>灵活的内容输出参数的数组。Default value: null
.
默认值: null code>。
‘templates’ (array) Array of templates for flexible content layouts.
“模板” strong> (数组) em>用于灵活内容布局的模板数组。In the templates use standard get_sub_field function
.
在模板中,使用标准的 get_sub_field函数 code>。
key (string) – layout name
键(string) em> –布局名称
value (string|array) arguments for get_template_part
function.
get_template_part code>函数的值(string | array) em>参数。 p>Requires Advanced Custom Fields (Pro)
需要高级自定义字段(Pro) em> p>Examples
示例 h4>
Link field
链接字段 strong> p> <?php acf_snippet_the_link('more_info_link', false, [
acf_snippet_the_link('more_info_link',false,[
'class'=> 'link__out',
'class'=>'link__out',
]
]
);
);
?>
?>
code> pre>
Image field
图片字段 strong> p> <?php echo acf_snippet_get_image('logo', 'option', [
回声acf_snippet_get_image('logo','option',[
'size' => 'medium',
'大小'=>'中等',
'alt' => 'company name',
'alt'=>'公司名称',
'title' => false,
'title'=>否,
'class' => 'header__logo',
'class'=>'header__logo',
'id' => 'company-logo',
'id'=>'company-logo',
'loading' => 'fetch',
'正在加载'=>'获取',
'link' => [
'链接'=> [
'href' => get_home_url()
'href'=> get_home_url()
]
]
]
]
);
);
?>
?>
code> pre>
Repeater field
中继器字段 strong> p> <?php acf_snippet_the_repeater( 'team_members', false, [
acf_snippet_the_repeater('team_members',false,[
'template' => [ 'templates/loops/loop', 'team-member' ],
'template'=> [''templates / loops / loop','team-member'],
'wrap_before' => '
', 'wrap_before'=>'
', 'wrap_after'=>' ul>',
'empty_html' => '
' .
'empty_html'=>'
'
__( 'No team members to show.', 'web' ) .
__('没有团队成员可以参加。','web')。
'
' ' p>'
]
]
);
);
?>
?>
code> pre>
Flexible content field
灵活的内容字段 strong> p> <?php acf_snippet_the_flexible_content( 'fp_content', false, [
acf_snippet_the_flexible_content('fp_content',false,[
'templates' => [
'模板'=> [
'slider' => [ 'templates/homepage/snippet', 'slider' ],
'slider'=> [''templates / homepage / snippet','slider'],
'counters' => [ 'templates/homepage/snippet', 'counters' ],
'counters'=> [''templates / homepage / snippet','counters'],
'text_block' => [ 'templates/homepage/snippet', 'text_block' ]
'text_block'=> ['templates / homepage / snippet','text_block']
]
]
]
]
);
);
code> pre>
?>
?>
`
` p>