0
我無法得到這個顯示來自我的自定義帖子類型名爲「資源」的帖子。任何幫助?爲什麼我的wordpress查詢不能工作?自定義帖子類型
<?php
add_action('pre_get_posts', 'add_custom_post_type_to_query');
function add_custom_post_type_to_query($query) {
if (is_home() && $query->is_main_query())
$query->set('post_type', array('post', 'page', 'resources'));
return $query;
}
?>
<?php if (have_posts()) : ?>
<?php /* Start the Loop */ ?>
<?php while (have_posts()) : the_post(); ?>
<?php the_title(); ?>
<?php the_content(); ?>
<?php get_template_part('content', get_post_format()); ?>
<?php endwhile; ?>
<?php twentytwelve_content_nav('nav-below'); ?>
<?php else : ?>
你把'add_custom_post_type_to_query'東西放在你的模板中了嗎?它應該駐留在你的'functions.php'文件中 – diggy 2013-04-25 19:48:12