【发布时间】:2016-04-06 16:32:16
【问题描述】:
我使用 ACF 创建了选项页面,并为帖子和类别创建了自定义分类。我添加到我的标题 get_field 以获取徽标,它在大部分页面上都可以正常工作..
在自定义分类类别页面上,我没有得到任何数据。我尝试 var_dump 和 print_r 等等..它什么也没有得到,我在谷歌上找不到答案..
这是我的代码-
header.php
<?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>';
}
?>
functions.php
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' );
这是我的Homepage,这是Archive page
我很沮丧..提前谢谢
【问题讨论】:
标签: php wordpress advanced-custom-fields