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">
$temp = $wp_query;
$page = get_query_var('page');
$page = (!empty($page) ? $page : 1);
$wp_query= null;
$wp_query = new WP_Query();
<?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 class="clear"></div-->

<div class="boxim">
if ( has_post_thumbnail() ) { ?>
    <a href="<?php the_permalink() ?>"><img class="boximg" src="<?php bloginfo('stylesheet_directory'); ?>/timthumb.php?src=<?php get_image_url(); ?>&amp;h=270&amp;w=180&amp;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 } ?>



<?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;?>

And this is my Post Type:

function post_type_movies() {
array( 'public' => true,
        'publicly_queryable' => true,
        'has_archive' => true, 
        'hierarchical' => false,
        'menu_icon' => get_stylesheet_directory_uri() . '/images/movie.png',
            '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,
        'query_var' => true,
        'rewrite' => TRUE,
        'rewrite' => array( 'slug' => 'pelicula', 'with_front' => FALSE,),
        'register_meta_box_cb' => 'mytheme_add_box',
        'supports' => array(
add_action('init', 'post_type_movies');

Check it out at http://ddlpremium.com/peliculeros

Thanks in advance.

  • 2
    Please show us your research efforts and explain why all the other solutions didn’t work in your case. ;) – fuxia Jul 31 '12 at 12:17

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 is paged not page. so,


$temp = $wp_query;
$page = get_query_var('page');


global $wp_query;
$temp = $wp_query;
$page = get_query_var('paged');

Check if that works. Also I prefer to use Singular for CPT names. movie instead of movies.


Have you tried using double quotes around the query string with the variable?





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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.