WordPress.org

Support

Support » How-To and Troubleshooting » [Resolved] Strange Issue with Custom Post Type Pagination

[Resolved] Strange Issue with Custom Post Type Pagination

  • I’m using a custom post type to display a series of videos on my site. I have about 30 videos, showing 5 per page. Initially, everything works fine. I can see my videos, I can hit Next or Previous and see more videos, and all is well.

    However, anytime I add a post, update a page, change a setting, add a plugin, change ANYTHING in the system no matter how small, my Next / Prev buttons return 404. If I go to Permalinks, change to default, then back to /%category%/%postname%/ everything works fine again … until I add a new post or change anything, then I get 404 again. I’ve tried using all the other standard Permalink setups with the same result, and default is not acceptable for my needs.

    Any thoughts on why this could be? Here is my code:

    <?php
    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    $loop = new WP_Query( array(
    'post_type' => 'videos',
    'posts_per_page' => 5,
    'paged'=>$paged
    ) ); ?>  
    
        <div id="nav-above" class="navigation">
    		<div class="nav-previous"><?php next_posts_link('&laquo; Older Videos', $loop->max_num_pages) ?></div>
    		<div class="nav-next"><?php previous_posts_link('Newer Videos &raquo;') ?></div>
            <div class="clear"><!-- clear --></div>
    	</div><!-- #nav-above -->
    
    <?php while ( $loop->have_posts() ) : $loop->the_post(); ?>
    
    <?php
    	$custom = get_post_custom($post->ID);
    	$youtube = $custom["videos-youtube"][0];
    ?>
    
    <div class="video-item">
    
    				<div class="video-info">
    					<h2 class="video-title"><?php the_title(); ?></h2>
    				</div><!-- video-info -->
    
    				<div class="video-player">
    
    					<object width="560" height="320"><param name="movie" value="http://www.youtube.com/v/<?=$youtube?>&hl=en_US&fs=1"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><param name="wmode" value="transparent"><embed src="http://www.youtube.com/v/<?=$youtube?>&hl=en_US&fs=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="560" height="320" wmode="transparent"></embed></object>
    				</div><!-- video-player -->
    			</div><!-- video-item -->
    
    <?php endwhile; ?>
    
    				<div id="nav-below" class="navigation">
    					<div class="nav-previous"><?php next_posts_link('&laquo; Older Videos', $loop->max_num_pages) ?></div>
    					<div class="nav-next"><?php previous_posts_link('Newer Videos &raquo;') ?></div>
                        <div class="clear"><!-- clear --></div>
    				</div><!-- #nav-below -->
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘[Resolved] Strange Issue with Custom Post Type Pagination’ is closed to new replies.