ここでコードと手順を使用しました:
http ://wp.miragearts.com/allinone-event-calendar-events-blog-home-categories-tags/
このコードをfunctions.phpに追加すると、まったく同じ名前とスラッグで2つのカテゴリ(通常の投稿用とイベントカスタム投稿用)を作成すると、基本的に1つのカテゴリを持つのと同じになることがわかりました。
これは私のサイトを少し遅くしているかもしれないと思いますが、それが問題を引き起こすかどうかを判断するのは本当に時期尚早です。
これがfunctions.phpのコードのコピーです。
// Add this to your theme's functions.php
function edit_my_query($query) {
// Modify category and tag listings to include ai1ec events and all uses of the same term
// across event and post taxonomies
// ie live-music or arts whether they are event or post categories
// also include ai1ec events in blog home and feeds
if ( ( is_home() || is_feed() || is_category() || is_tag() )
&& empty( $query->query_vars['suppress_filters'] ) ) {
// The 'suppress_filters' test above keeps your menus from breaking
$post_type = get_query_var('post_type');
if($post_type && $post_type[0] != 'post') {
$post_type = $post_type;
} else {
$post_type = array('post','ai1ec_event'); // add custom post types here
}
$query->set('post_type',$post_type);
if (is_category() || is_tag()) {
// Add custom taxonomies to category and tag pages
if (is_category()) {
$taxonomy1 = 'category';
$taxonomy2 = 'events_categories';
}
if (is_tag()){
$taxonomy1 = 'post_tag';
$taxonomy2 = 'events_tags';
}
$queried_object = $query->get_queried_object();
$slug = $queried_object->slug;
$query->set('tax_query', array(
'relation' => 'OR',
array(
'taxonomy' => $taxonomy1, 'field' => 'slug', 'terms' => $slug
),
array(
'taxonomy' => $taxonomy2, 'field' => 'slug', 'terms' => $slug
)
));
}
}
}
add_action('pre_get_posts', 'edit_my_query');