我使用的代码和指令在这里: http://wp.miragearts.com/allinone-event-calendar-events-blog-home-categories-tags/
我发现这个代码添加到了functions.php,如果我创建了两个类别(一个用于常规pos ts和一个用于事件定制的帖子),它们的名称和slu exact相同,然后它与拥有一个类别基本相同。
我认为这可能会使我的网站变慢一点,但现在确定它是否会引起问题还为时尚早。
下面是对的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');
是的,它是可能的,但取决于你使用的是定义你的职位类型的插件。那么这个插件是什么? – soju 2012-04-25 07:05:57
我还没有确定事件插件,但我可能会使用** All-in-One事件日历**。 – danapaige 2012-04-25 19:45:45