帮助!我失去了理智!!
我有一个页面显示我需要分页的自定义帖子类型'rm',但是当我点击第2页时,即使我使用了
,我也会得到一个404页面<?php $paged = ( get_query_var('page') ) ? get_query_var('page') : 1; ?>
我已经在互联网上寻找解决方案,但找不到任何东西。有没有人知道出了什么问题?
这是我的自定义帖子类型注册 -
<?php /* RM SHOWCASE CREATION */
add_action('init', 'rm_register');
function rm_register() {
$labels = array(
'name' => _x('Rich media', 'post type general name'),
'singular_name' => _x('Creative', 'post type singular name'),
'add_new' => _x('Add New', 'Creative item'),
'add_new_item' => __('Add New Creative'),
'edit_item' => __('Edit Creative'),
'new_item' => __('New Creative'),
'view_item' => __('View Creative'),
'search_items' => __('Search Creative'),
'not_found' => __('Nothing found'),
'not_found_in_trash' => __('Nothing found in Trash'),
'parent_item_colon' => '',
);
$args = array(
'labels' => $labels,
'public' => true,
'publicly_queryable' => true,
'show_ui' => true,
'query_var' => true,
'rewrite' => array( 'slug' => 'rich-media-showcase'),
'capability_type' => 'post',
'hierarchical' => false,
'menu_position' => null,
'supports' => array('title','editor','thumbnail'),
'taxonomies' => array( 'verticals','features','device'),
'has_archive' => false
);
register_post_type( 'rm' , $args );
}?&gt;
这是我的询问......
<?php do_action('show_beautiful_filters', 'rm'); ?>
<?php // set up or arguments for our custom query
$paged = ( get_query_var('page') ) ? get_query_var('page') : 1;
$query_args = array(
'post_type' => 'rm',
'paged' => $paged,
);
// create a new instance of WP_Query
$the_query = new WP_Query( $query_args ); ?>
<?php if ( $the_query->have_posts() ) : while ( $the_query->have_posts() ) : $the_query->the_post(); // run the loop ?>
<a class="creativeURL" href="<?php the_field('creative_url'); ?>" target="_blank" >
<article class="creative">
<img class="creativeImg" src="<?php the_field('cover_photo'); ?>" alt="<?php the_title(); ?>"/>
<h1><?php the_title(); ?></h1>
</article>
</a>
<?php endwhile; ?>
<?php if ($the_query->max_num_pages > 1) { // check if the max number of pages is greater than 1 ?>
<nav class="prev-next-posts">
<div class="prev-posts-link">
<?php echo get_next_posts_link( 'Older Entries', $the_query->max_num_pages ); // display older posts link ?>
</div>
<div class="next-posts-link">
<?php echo get_previous_posts_link( 'Newer Entries' ); // display newer posts link ?>
</div>
</nav>
<?php } ?>
<?php // clean up after our query
wp_reset_postdata(); ?>
<?php else: ?>
<article>
<h1>Sorry...</h1>
<p><?php _e('Sorry, no posts matched your criteria.'); ?></p>
</article>
由于 菲尔
答案 0 :(得分:0)
如果使用?page = 2而不是page / 2 ??
,它是否有效您是否有一个与自定义帖子类型存档名称相同的页面?
您是否尝试重新保存永久链接?