我正在使用高级自定义字段制作WP网站.在一个页面上,我想回显一个包含所有类别为"Studio"的帖子的循环.然后我想显示名为"studio_project_dia_img"的子字段中的第一个图像.我可以从repeater_field获取所有图像,但不仅仅是第一个
此代码有效(仅响应来自转发器字段的所有行):
<div <?php post_class() ?> id="post-<?php the_ID(); ?>">
<li class="thumbs">
<a href="studio-single.html" class="clearfix">
<?php if (get_field('studio_project_dia')) : while(has_sub_field('studio_project_dia')): ?>
<img src="<?php echo get_sub_field('studio_project_dia_img', $post->ID); ?>" />
<?php endwhile; endif; ?>
<div class="thumbsText">
<h2><?php the_title(); ?></h2>
<h3><?php the_tags( 'Tags: ', ' / ', ''); ?></h3>
</div>
</a>
</div>
<?php edit_post_link('Edit this entry','','.'); ?>
</div>
<?php endwhile; endif; ?>
Run Code Online (Sandbox Code Playgroud)
这段代码没有:
<div <?php post_class() ?> id="post-<?php the_ID(); ?>">
<li class="thumbs">
<a href="studio-single.html" class="clearfix">
<?php if (get_field('studio_project_dia')) : while(has_sub_field('studio_project_dia')): ?>
<?php
$rows = get_sub_field('studio_project_dia_img', …Run Code Online (Sandbox Code Playgroud) 我在我的网站上使用高级自定义字段.
我有一个名为anime_par的转发器字段,sub_field称为animateur.子字段animateur是一个后对象.
我在我的页面中的循环中使用它,这个循环显示自定义帖子类型中的类别的帖子.
我要做的是在我的页面中显示animateur选择的帖子名称和帖子链接.
这是我正在使用的代码,但它不起作用,它显示我当前页面的永久链接,而不是在自定义字段中选择的代码.
<?php while(has_sub_field('anime_par')): ?>
<a href="<?php echo get_permalink('the_sub_field("animateur")'); ?>"><?php echo get_title('the_sub_field("animateur")'); ?></a>
<?php endwhile; ?>
Run Code Online (Sandbox Code Playgroud)
有什么建议使这项工作?
谢谢你的帮助,
我需要获取子页面列表,但我需要排除第一个孩子.我还需要显示一个名为'page_icon'的自定义图像字段,其中包含网址和页面标题.这将作为将在每个子页面上显示的子菜单.每个菜单项都需要将当前类附加到a标记.我已经尝试了许多不同的方法并没有运气,因为我的技能水平充其量只是初学者.
父ID是1064,自定义字段称为"page_icon",它是使用ACF设置的
当前菜单硬编码到编辑器中,html如下所示: -
<div id="attachment_1306" style="width: 160px" class="wp-caption alignleft"><a class="icon on" href="http://www.domain.co.uk/category/category/category/"><img class="wp-image-1306 size-thumbnail" title="Policy Manager" src="http://www.domain.co.uk/wp-content/uploads/2013/05/docs-150x150.png" alt="" width="150" height="150" /></a><p class="wp-caption-text">Policy Manager</p></div>
<div id="attachment_1297" style="width: 160px" class="wp-caption alignleft"><a class="icon" href="http://www.domain.co.uk/category/category/category/"><img class="wp-image-1297 size-thumbnail" title="Risk Manager" src="http://www.domain.co.uk/wp-content/uploads/2013/05/risk-150x150.png" alt="" width="150" height="150" /></a><p class="wp-caption-text">Risk Manager</p></div>
<div id="attachment_1307" style="width: 160px" class="wp-caption alignleft"><a class="icon" title="Controls Manager" href="http://www.domain.co.uk/governance-risk-and-category/category/category/"><img class="wp-image-1307 size-thumbnail" title="Controls Manager" src="http://www.domain.co.uk/wp-content/uploads/2013/05/controls-150x150.png" alt="" width="150" height="150" /></a><p class="wp-caption-text">Controls Manager</p></div>
<div id="attachment_1301" style="width: 160px" class="wp-caption alignleft"><a class="icon" title="Incident Manager" href="http://www.domain.co.uk/category/category/category/"><img class="wp-image-1301 size-thumbnail" title="Incident Manager" src="http://www.domain.co.uk/wp-content/uploads/2013/05/incident-150x150.png" alt="" …Run Code Online (Sandbox Code Playgroud) 我一直在使用高级自定义字段创建我自己的WP主题,我继续输入代码如下:
<?php
if(get_field('featured_courses_heading_text', 'option')) {
echo get_field('featured_courses_heading_text', 'option');
}
?>
Run Code Online (Sandbox Code Playgroud)
是否有一个更精简的代码版本,我可以使用三元运算符?我试着查看文档,但找不到任何东西
php wordpress wordpress-theming ternary-operator advanced-custom-fields
如何以编程方式将包含已填充的高级自定义字段的新帖子创建并插入到数据库中?
因此,我需要在ACF(高级自定义字段)"选项"页面下添加我自己的自定义页面,该页面是我使用ACF站点中的正确代码创建的,该页面工作正常.
所以我做的是这样的:
function options_invoiceno(){ ?>
<div class="wrap">
<h1>testing sub page</h1>
</div>
<?php }
function add_theme_menu_item() {
add_submenu_page(
"acf-options-invoice-design",
"sub page",
"sub page",
"manage_options",
"invoice-number",
"options_invoiceno"
);
}
add_action("admin_menu", "add_theme_menu_item");
Run Code Online (Sandbox Code Playgroud)
它给了我"选项"下边栏中的子菜单:
但是当我点击进入菜单项时,我得到一个404 Not Found页面并且URL不正确:例如 http://example.com/wp-admin/acf-options-invoice-design-sub
我错过了什么吗?这甚至可以在现有的ACF菜单下添加子菜单吗?
任何帮助或指示将不胜感激.
我很困惑如何计算AR,MA,ARMA和ARIMA中的ACF和PAC的q.例如,在R中,我们使用acf或pacf来获得最佳的p和q.
但是,根据我读过的信息,p是AR的顺序,q是MA的顺序.假设p = 2,则AR(2)应该是y_t = a y_t-1 + b y_t-2 + c.我们可以在滞后= 1,2,3 ....时计算acf函数(在R中),以找出哪个滞后带来最大的acf函数值.对于决定q,MA也会发生同样的事情.但是,这是否意味着已经建立了p和q?
我猜这是步骤.但我不确定我是否正确.所以,让我们说在R的函数acf和pacf中,这是真正的过程:1.对于p = 1,设置lag = 1,2,3,... max以查看哪个滞后具有最大的自相关值.2.对于p = 2,3,4 ......,做同样的事情来找到滞后.3.将这些值相互比较.假设当p = 2且滞后= 4时,最大的自相关值出现,当我们说AR的顺序时,即.p,是2?
云有人请给我一个例子,说明如何估计p和q?
当您有很多选项时,ACF后端/管理面板会变得非常混乱.我看到你可以在哪里更改宽度百分比并将自己的类添加到自定义字段中,但是如何设置这些类的样式?只是将这些类名添加到style.css不起作用!
我是从字段的名称属性中获得的
name="field[a][2][b][0][c][1][field_name]"
Run Code Online (Sandbox Code Playgroud)
序列化表格后,我得到了:
array('field[a][2][b][0][c][1][field_name]'=>'value')
Run Code Online (Sandbox Code Playgroud)
我需要将其转换为以下数组:
$field = array (
'a' => array (
[2] => array (
'b' => array (
[0] => array (
'c' => array (
[1] => array (
'field_name'=>'value'
)
)
)
)
)
)
);
Run Code Online (Sandbox Code Playgroud)
我需要某种foreach函数或php可以将该字符串识别为数组吗?
我正在使用高级自定义字段来创建特定类别的帖子。我使用Elementor(免费版)进行格式化,我希望所有使用ACF创建的帖子都应显示在我页面的特定部分下。但是,我无法做到这一点,因为elementor pro支持此功能,并且我无法在elementor中编写php。
关于如何做到这一点的任何想法?
wordpress wordpress-theming custom-wordpress-pages advanced-custom-fields elementor