我正在处理一个带有自定义帖子类型的主题
目前的问题是,我正在将布局文件保存在一个名为templates的文件夹中。。在头版。php我正在使用选项检查来查看用户从主题面板中选择了哪种类型的布局。。并包括该文件
目前在自定义帖子类型模板中,分页不起作用。。我正在使用此循环:
global $wp_query;
$temp = $wp_query;
$wp_query= null;
$wp_query = new WP_Query();
$wp_query->query(\'post_type=portfolio&paged=\'.$paged);
if ($wp_query->have_posts()) : while ($wp_query->have_posts()) : $wp_query->the_post();
......
<?php endwhile; endif; ?>
..
<?php
if (function_exists("pagination")) {
pagination($additional_loop->max_num_pages);}
?>
<?php $wp_query = null; $wp_query = $temp;?>
分页显示,但链接显示为/page/2/。。运行时显示404。。在我看来,它显示了主查询的第2页,因为没有多少帖子添加了404。
我也尝试过:
$paged = 1;
if ( get_query_var(\'paged\') ) $paged = get_query_var(\'paged\');
if ( get_query_var(\'page\') ) $paged = get_query_var(\'page\');
没用
我的自定义后期注册结构:
function my_custom_post_portfolio() {
$labels = array(
\'name\' => _x( \'Portfolio\', \'post type general name\' ),
\'singular_name\' => _x( \'Portfolio\', \'post type singular name\' ),
\'add_new\' => _x( \'Add New\', \'book\' ),
\'add_new_item\' => __( \'Add New Item\' ),
\'edit_item\' => __( \'Edit Item\' ),
\'new_item\' => __( \'New Portfolio Item\' ),
\'all_items\' => __( \'All Items\' ),
\'view_item\' => __( \'View Items\' ),
\'search_items\' => __( \'Search Portfolio\' ),
\'not_found\' => __( \'No Portfolio found\' ),
\'not_found_in_trash\' => __( \'No Portfolio found in the Trash\' ),
\'parent_item_colon\' => \'\',
\'menu_name\' => \'Portfolio\'
);
$args = array(
\'labels\' => $labels,
\'description\' => \'Holds our Portfolio and product specific data\',
\'public\' => true,
\'menu_position\' => 5,
\'supports\' => array( \'title\', \'editor\', \'thumbnail\', \'excerpt\', \'comments\' ),
\'has_archive\' => true,
\'rewrite\' => array( \'slug\' => \'portfolio\', \'with_front\' => true ),
\'_builtin\' => false, // It\'s a custom post type, not built in!
\'query_var\' => true,
\'taxonomies\' => array(\'portfolio\', \'post_tag\') // this is IMPORTANT
);
register_post_type( \'Portfolio\', $args );
}
add_action( \'init\', \'my_custom_post_portfolio\' );
感谢您的帮助!谢谢:)