I’m using a template, which uses Custom Post Type ‘movies’. When I try to change the page I got 404 Not Found 🙁
This is my index.php
<div id="content">
<?php
$temp = $wp_query;
$page = get_query_var('page');
$page = (!empty($page) ? $page : 1);
$wp_query= null;
$wp_query = new WP_Query();
$wp_query->query('post_type=movies'.'&posts_per_page=6&paged=$page');
?>
<?php while (have_posts()) : the_post(); ?>
<div class="box " id="post-<?php the_ID(); ?>">
<div class="boxentry">
<div class="btitle">
<h2 align="center"><a href="<?php the_permalink() ?>" rel="bookmark" title="Ver <?php the_title(); ?>"><?php echo get_post_meta($post->ID, 'wtf_ryear', true); ?></a></h2>
</div>
<!--div class="clear"></div-->
</div>
<div class="boxim">
<?php
if ( has_post_thumbnail() ) { ?>
<a href="<?php the_permalink() ?>"><img class="boximg" src="<?php bloginfo('stylesheet_directory'); ?>/timthumb.php?src=<?php get_image_url(); ?>&h=270&w=180&zc=1" alt=""/></a>
<?php } else { ?>
<a href="<?php the_permalink() ?>"><img class="boximg" src="<?php bloginfo('template_directory'); ?>/images/dummy.png" alt="" /></a>
<?php } ?>
</div>
</div>
<?php if(++$counter % 4 == 0) : ?>
<div class="clear"></div>
<?php endif; ?>
<?php endwhile; ?>
<div class="clear"></div>
<?php getpagenavi(); ?>
<?php $wp_query = null; $wp_query = $temp;?>
</div>
And this is my Post Type:
function post_type_movies() {
register_post_type(
'movies',
array( 'public' => true,
'publicly_queryable' => true,
'has_archive' => true,
'hierarchical' => false,
'menu_icon' => get_stylesheet_directory_uri() . '/images/movie.png',
'labels'=>array(
'name' => _x('Movies', 'post type general name'),
'singular_name' => _x('Movie', 'post type singular name'),
'add_new' => _x('Add New', 'Movies'),
'add_new_item' => __('Add New Movie'),
'edit_item' => __('Edit Movie'),
'new_item' => __('New Movie'),
'view_item' => __('View Movie'),
'search_items' => __('Search Movies'),
'not_found' => __('No Movies found'),
'not_found_in_trash' => __('No Movie found in Trash'),
'parent_item_colon' => ''
),
'show_ui' => true,
'menu_position'=>5,
'query_var' => true,
'rewrite' => TRUE,
'rewrite' => array( 'slug' => 'pelicula', 'with_front' => FALSE,),
'register_meta_box_cb' => 'mytheme_add_box',
'supports' => array(
'title',
'thumbnail',
'comments',
'editor'
)
)
);
}
add_action('init', 'post_type_movies');
Check it out at http://ddlpremium.com/peliculeros
Thanks in advance.
Couple of small corrections:
$wp_query
is a global variable so you need to declear it as a global and i believe the query var ispaged
notpage
. so,change
to
Check if that works. Also I prefer to use Singular for CPT names.
movie
instead ofmovies
.Have you tried using double quotes around the query string with the variable?
Change:
to
If that doesn’t fix it, try dumping the query after the above code
var_dump( $wp_query )
it may show what is causing the issue.