WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Strange Issue with Custom Post Type Pagination (4 posts)

  1. DaveRH
    Member
    Posted 3 years ago #

    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 -->
  2. DaveRH
    Member
    Posted 3 years ago #

    when I change my Permalinks back to default, everything works fine... the problem comes when I use any other Permalink structure, standard or custom...

  3. keesiemeijer
    moderator
    Posted 3 years ago #

  4. DaveRH
    Member
    Posted 3 years ago #

    thank you, it seems to be working now

    changing rewrite to

    'rewrite'               => array( 'slug' => 'video' ),

    when registering my post type did the trick

    thanks

Topic Closed

This topic has been closed to new replies.

About this Topic