Php Can';在自定义分类存档页上获取选项页自定义字段
我使用ACF创建了选项页面,并为帖子和类别创建了自定义分类法。我在页眉的get_字段中添加了logo,它在页面的大部分部分都很好地工作 在自定义分类类别页面上,我没有得到任何数据。。我试着把垃圾倒出来 还有打印什么的。。它什么也得不到,我在谷歌上也找不到答案 这是我的密码- header.phpPhp Can';在自定义分类存档页上获取选项页自定义字段,php,wordpress,advanced-custom-fields,Php,Wordpress,Advanced Custom Fields,我使用ACF创建了选项页面,并为帖子和类别创建了自定义分类法。我在页眉的get_字段中添加了logo,它在页面的大部分部分都很好地工作 在自定义分类类别页面上,我没有得到任何数据。。我试着把垃圾倒出来 还有打印什么的。。它什么也得不到,我在谷歌上也找不到答案 这是我的密码- header.php <?php if (get_field('konimhakol_logo', 'options')) { $site_logo = get_fiel
<?php
if (get_field('konimhakol_logo', 'options')) {
$site_logo = get_field('konimhakol_logo', 'options');
echo '<a href="'. get_bloginfo('url') .'" title="'. get_bloginfo('name') .'"><img src="'. $site_logo['url'] .'" alt="'. $site_logo['title'] .'"></a>';
}
?>
function create_businesses_post_type() {
register_post_type('kh_businesses',
array(
'labels' => array(
'name' => __('עסקים'),
'singular_name' => __('עסק'),
'add_new' => __('הוסף עסק')
),
'menu_icon' => 'dashicons-admin-home',
'taxonomies' => array('category', 'post_tag'),
'supports' => array('title', 'editor', 'thumbnail', 'custom-fields'),
'public' => true,
'has_archive' => true,
'rewrite' => array('slug' => 'businesses'),
)
);
}
add_action( 'init', 'create_businesses_post_type' );
// Add Businesses Post Type to Archives
function archives_add_custom_types($query) {
if(is_category() || is_tag() && empty($query->query_vars['suppress_filters'])) {
$query->set('post_type', array('kh_businesses'));
return $query;
}
}
add_filter( 'pre_get_posts', 'archives_add_custom_types' );
这是我的,这是
我很沮丧。。提前感谢您的get_field()调用应该如下所示:
get_field('konimhakol_logo', 'option')
您有“选项”,但ACF的文档要求“选项”
您的get\u field()调用应该如下所示:
get_field('konimhakol_logo', 'option')
您有“选项”,但ACF的文档要求“选项”
好的,我找到问题了!
为了获得新类别下的帖子,我将此代码添加到functions.php文件中-
// Add Businesses Post Type to Archives
function archives_add_custom_types($query) {
if(is_category() || is_tag() && empty($query->query_vars['suppress_filters'])) {
$query->set('post_type', array('kh_businesses'));
return $query;
}
}
add_filter( 'pre_get_posts', 'archives_add_custom_types' );
但是当我删除它时,标题会返回,但是在我的业务类别下没有帖子…好的,我发现了问题!
为了获得新类别下的帖子,我将此代码添加到functions.php文件中-
// Add Businesses Post Type to Archives
function archives_add_custom_types($query) {
if(is_category() || is_tag() && empty($query->query_vars['suppress_filters'])) {
$query->set('post_type', array('kh_businesses'));
return $query;
}
}
add_filter( 'pre_get_posts', 'archives_add_custom_types' );
但是当我删除它时,标题会回来,但是在我的业务类别下没有帖子…谢谢,我现在刚刚尝试过,我一直得到相同的结果这是一个干净的下划线主题,我自己添加了自定义帖子类型。。也许我遗漏了什么?在选项页面上调用自定义字段时,自定义文章类型和分类归档应该是无关的。我经常在所有页面模板和自定义文件上使用get_字段(“”,'选项'),我从来没有遇到过任何问题。您是否有任何名为“option”或“options”的帖子类型或分类法可能会导致冲突?或者,您的主题是否会利用“option”或“options”进行某些主题自定义,并且可能会导致冲突。这是我唯一的自定义帖子类型(业务),它是一个干净的下划线主题。我刚刚注意到,当我进入nav-menus.php选项屏幕时,只有企业,它们的类别在常规WordPress类别下Hanks,我现在刚刚尝试过,我一直得到相同的结果这是一个干净的下划线主题,我自己添加了自定义帖子类型。。也许我遗漏了什么?在选项页面上调用自定义字段时,自定义文章类型和分类归档应该是无关的。我经常在所有页面模板和自定义文件上使用get_字段(“”,'选项'),我从来没有遇到过任何问题。您是否有任何名为“option”或“options”的帖子类型或分类法可能会导致冲突?或者,您的主题是否会利用“option”或“options”进行某些主题自定义,并且可能会导致冲突。这是我唯一的自定义帖子类型(业务),它是一个干净的下划线主题。我刚刚注意到,当我进入nav-menus.php选项屏幕时,只有企业和它们的类别在常规WordPress类别下。我如何将自定义帖子类型添加到我的结果页面?我尝试了在谷歌上找到的一些代码,但都不管用。我如何才能将自定义帖子类型添加到我的结果页面?我尝试了在谷歌上找到的一些代码,但都不管用