我正在使用高级自定义字段插件将一些字段分配给具有特定类别的帖子,但这些字段在我发布帖子之前不会出现。
我在仪表板上做了一些链接,因此我的客户只需单击“新产品”等,然后就可以添加已选择类别为“产品”的新帖子。但是,因为我的客户必须在这篇新文章“属于”类别“产品”之前发布它,所以我通过高级自定义字段分配给“产品”的字段不存在。
有人知道我如何解决这个问题吗?
我正在使用高级自定义字段插件将一些字段分配给具有特定类别的帖子,但这些字段在我发布帖子之前不会出现。
我在仪表板上做了一些链接,因此我的客户只需单击“新产品”等,然后就可以添加已选择类别为“产品”的新帖子。但是,因为我的客户必须在这篇新文章“属于”类别“产品”之前发布它,所以我通过高级自定义字段分配给“产品”的字段不存在。
有人知道我如何解决这个问题吗?
除了@Milo链接的解决方案之外,另一个选项是从字段组中删除类别规则,并使用jQuery控制此ACF组的可见性。
因此,假设带有ACF字段的元框具有id#acf_79
并且您希望将其分配给ID为的类别1
, 渲染为#in-category-1
在类别元框中,将执行以下操作
使用浏览器检查器获取正确的ID
add_action( \'admin_footer-post.php\', \'conditional_acf_metabox_wpse_78772\' );
add_action( \'admin_footer-post-new.php\', \'conditional_acf_metabox_wpse_78772\' );
function conditional_acf_metabox_wpse_78772()
{
// Not our post type, do nothing. Adjust if using another post_type.
global $current_screen;
if ( \'post\' != $current_screen->post_type )
return;
?>
<script type="text/javascript">
jQuery(document).ready( function($)
{
// For a smoother effect, hide the box with CSS and show it if "is(\':checked\')"
if( ! $(\'#in-category-1\').attr(\'checked\') )
$(\'#acf_79\').hide();
// Watch the behavior of Category 1 checkbox
$(\'#in-category-1\').change( function ()
{
// Show/Hide the ACF meta box
if( $(this).is(\':checked\') )
{
$(\'#acf_79\').slideDown();
}
else
{
$(\'#acf_79\').slideUp();
}
});
});
</script>
<?php
}
我购买了这个模板,我正在尝试自定义。我添加了一个名为location的新分类法类别,并试图用新的分类法类别替换主题中加载的默认类别。以下是当前代码及其加载类别的位置: $cats_array = get_categories(\'hide_empty=0\'); $pages_array = get_pages(\'hide_empty=0\'); $site_pages = array(); $site_cats = array(); foreach (
我正在使用高级自定义字段插件将一些字段分配给具有特定类别的帖子,但这些字段在我发布帖子之前不会出现。
我在仪表板上做了一些链接,因此我的客户只需单击“新产品”等,然后就可以添加已选择类别为“产品”的新帖子。但是,因为我的客户必须在这篇新文章“属于”类别“产品”之前发布它,所以我通过高级自定义字段分配给“产品”的字段不存在。
有人知道我如何解决这个问题吗?
除了@Milo链接的解决方案之外,另一个选项是从字段组中删除类别规则,并使用jQuery控制此ACF组的可见性。
因此,假设带有ACF字段的元框具有id#acf_79
并且您希望将其分配给ID为的类别1
, 渲染为#in-category-1
在类别元框中,将执行以下操作
使用浏览器检查器获取正确的ID
add_action( \'admin_footer-post.php\', \'conditional_acf_metabox_wpse_78772\' );
add_action( \'admin_footer-post-new.php\', \'conditional_acf_metabox_wpse_78772\' );
function conditional_acf_metabox_wpse_78772()
{
// Not our post type, do nothing. Adjust if using another post_type.
global $current_screen;
if ( \'post\' != $current_screen->post_type )
return;
?>
<script type="text/javascript">
jQuery(document).ready( function($)
{
// For a smoother effect, hide the box with CSS and show it if "is(\':checked\')"
if( ! $(\'#in-category-1\').attr(\'checked\') )
$(\'#acf_79\').hide();
// Watch the behavior of Category 1 checkbox
$(\'#in-category-1\').change( function ()
{
// Show/Hide the ACF meta box
if( $(this).is(\':checked\') )
{
$(\'#acf_79\').slideDown();
}
else
{
$(\'#acf_79\').slideUp();
}
});
});
</script>
<?php
}
如何按其最近帖子的发布日期获得5个类别的排序?我基本上需要在最近的帖子中使用的5个最新类别。