• Hi All,

    Been working at this for about 8 hours and I just can’t see what the issue is.

    I have 3 custom post types on a site, and they are all functioning for the most part.

    However, even if I hard set the rewrite slug to be something, it always appears the custom posts are in the ‘news’ category. (The only category that exists through the admin interface if i go to posts -> category).

    for example, a url should be;

    top level;
    http://www.blazinone.com/top15s/

    what it is currently when hovering on pagination;
    http://www.blazinone.com/news/top-15-for-sunday-february-20-2011/

    what it should be when hovering on pagination;
    http://www.blazinone.com/top15s/top-15-for-sunday-february-20-2011/

    As you can see, the custom post content is displaying, so that is correct (after fixing the lowercase issue of my custom post types).

    I have also tried;
    1. multiple resets / regeneration of htaccess file
    2. changing permalink structure to default and back and resaving
    3. the pagination fix plugin
    4. the other plugin mentioned in the wordpress 3.1 gotcha’s document
    5. various types of pagination code i’ve found on the forums that have fixed it for others.

    I think my problem is different, because the custom posts are showing with the category as ‘news’ when it should be the custom post type I believe.

    Here’s the code for custom post type;

    add_action('init', 'top15_register');
    
    	function top15_register() {
    
    		$labels = array(
    			'name' => _x('Top 15 Tracks', 'Top 15 Tracks'),
    			'singular_name' => _x('top15', 'Top 15'),
    			'add_new' => _x('Add New', 'top15'),
    			'add_new_item' => __('Add New Top 15 Tracks List'),
    			'edit_item' => __('Edit Top 15'),
    			'new_item' => __('New Top 15'),
    			'view_item' => __('View Top 15'),
    			'search_items' => __('Search Top 15 Tracks'),
    			'not_found' =>  __('No top 15 found'),
    			'not_found_in_trash' => __('No top 15 found in Trash'),
    			'parent_item_colon' => '',
    			'menu_name' => 'Top 15'
    		);
        	$args = array(
       		    'labels' => $labels,
            	'label' => __('Top 15 Tracks'),
            	'singular_label' => __('Top 15'),
    			 'public' => true,
    			'publicly_queryable' => true,
    			'show_ui' => true,
    			'show_in_menu' => true,
    			'query_var' => true,
    
            	'public' => true,
            	'show_ui' => true,
            	'capability_type' => 'post',
            	'hierarchical' => false,
            	'rewrite' => array('slug'=>'top15','with_front'=>false),
    
            	'supports' => array('title')
            );
        register_post_type('top15',$args);
    	}
    
    	add_action("admin_init", "top15_init");
    	add_action('save_post', 'save_artists');
        add_action('save_post', 'save_tracks');
    
    	function top15_init(){
    		add_meta_box("top15Info-meta", "Enter Top 15 Tracks", "top15_meta_options", "top15", "normal", "low");
    	}
    
    	function top15_meta_options(){
    		global $post;
    		$custom = get_post_custom($post->ID);
    		$artist1 = $custom["artist1"][0];
    		$artist2 = $custom["artist2"][0];
    		$artist3 = $custom["artist3"][0];
    		$artist4 = $custom["artist4"][0];
    		$artist5 = $custom["artist5"][0];
    		$artist6 = $custom["artist6"][0];
    		$artist7 = $custom["artist7"][0];
    		$artist8 = $custom["artist8"][0];
    		$artist9 = $custom["artist9"][0];
    		$artist10 = $custom["artist10"][0];
    		$artist11 = $custom["artist11"][0];
    		$artist12 = $custom["artist12"][0];
    		$artist13 = $custom["artist13"][0];
    		$artist14 = $custom["artist14"][0];
    		$artist15 = $custom["artist15"][0];
    		$track1 = $custom["track1"][0];
    		$track2 = $custom["track2"][0];
    		$track3 = $custom["track3"][0];
    		$track4 = $custom["track4"][0];
    		$track5 = $custom["track5"][0];
    		$track6 = $custom["track6"][0];
    		$track7 = $custom["track7"][0];
    		$track8 = $custom["track8"][0];
    		$track9 = $custom["track9"][0];
    		$track10 = $custom["track10"][0];
    		$track11 = $custom["track11"][0];
    		$track12 = $custom["track12"][0];
    		$track13 = $custom["track13"][0];
    		$track14 = $custom["track14"][0];
    		$track15 = $custom["track15"][0];
    ?>
    <h1>To Enter Top 15 Tracks</h1>
    <p>Enter the title and date above and then enter all your tracks below.</p>
    <br />
    	<label style="margin-left: 10px; margin-right: 10px;">Artist 01:</label><input name="artist1" value="<?php echo $artist1; ?>" />
    	<label style="margin-left: 10px; margin-right: 10px;">Track 01:</label><input name="track1" value="<?php echo $track1; ?>" />
    	<br />
    	<label style="margin-left: 10px; margin-right: 10px;">Artist 02:</label><input name="artist2" value="<?php echo $artist2; ?>" />
    	<label style="margin-left: 10px; margin-right: 10px;">Track 02:</label><input name="track2" value="<?php echo $track2; ?>" />
    	<br />
    	<label style="margin-left: 10px; margin-right: 10px;">Artist 03:</label><input name="artist3" value="<?php echo $artist3; ?>" />
    	<label style="margin-left: 10px; margin-right: 10px;">Track 03:</label><input name="track3" value="<?php echo $track3; ?>" />
    	<br />
    	<label style="margin-left: 10px; margin-right: 10px;">Artist 04:</label><input name="artist4" value="<?php echo $artist4; ?>" />
    	<label style="margin-left: 10px; margin-right: 10px;">Track 04:</label><input name="track4" value="<?php echo $track4; ?>" />
    	<br />
    	<label style="margin-left: 10px; margin-right: 10px;">Artist 05:</label><input name="artist5" value="<?php echo $artist5; ?>" />
    	<label style="margin-left: 10px; margin-right: 10px;">Track 05:</label><input name="track5" value="<?php echo $track5; ?>" />
    	<br />
    	<label style="margin-left: 10px; margin-right: 10px;">Artist 06:</label><input name="artist6" value="<?php echo $artist6; ?>" />
    	<label style="margin-left: 10px; margin-right: 10px;">Track 06:</label><input name="track6" value="<?php echo $track6; ?>" />
    	<br />
    	<label style="margin-left: 10px; margin-right: 10px;">Artist 07:</label><input name="artist7" value="<?php echo $artist7; ?>" />
    	<label style="margin-left: 10px; margin-right: 10px;">Track 07:</label><input name="track7" value="<?php echo $track7; ?>" />
    	<br />
    	<label style="margin-left: 10px; margin-right: 10px;">Artist 08:</label><input name="artist8" value="<?php echo $artist8; ?>" />
    	<label style="margin-left: 10px; margin-right: 10px;">Track 08:</label><input name="track8" value="<?php echo $track8; ?>" />
    	<br />
    	<label style="margin-left: 10px; margin-right: 10px;">Artist 09:</label><input name="artist9" value="<?php echo $artist9; ?>" />
    	<label style="margin-left: 10px; margin-right: 10px;">Track 09:</label><input name="track9" value="<?php echo $track9; ?>" />
    	<br />
    	<label style="margin-left: 10px; margin-right: 10px;">Artist 10:</label><input name="artist10" value="<?php echo $artist10; ?>" />
    	<label style="margin-left: 10px; margin-right: 10px;">Track 10:</label><input name="track10" value="<?php echo $track10; ?>" />
    	<br />
    	<label style="margin-left: 10px; margin-right: 10px;">Artist 11:</label><input name="artist11" value="<?php echo $artist11; ?>" />
    	<label style="margin-left: 10px; margin-right: 10px;">Track 11:</label><input name="track11" value="<?php echo $track11; ?>" />
    	<br />
    	<label style="margin-left: 10px; margin-right: 10px;">Artist 12:</label><input name="artist12" value="<?php echo $artist12; ?>" />
    	<label style="margin-left: 10px; margin-right: 10px;">Track 12:</label><input name="track12" value="<?php echo $track12; ?>" />
    	<br />
    	<label style="margin-left: 10px; margin-right: 10px;">Artist 13:</label><input name="artist13" value="<?php echo $artist13; ?>" />
    	<label style="margin-left: 10px; margin-right: 10px;">Track 13:</label><input name="track13" value="<?php echo $track13; ?>" />
    	<br />
    	<label style="margin-left: 10px; margin-right: 10px;">Artist 14:</label><input name="artist14" value="<?php echo $artist14; ?>" />
    	<label style="margin-left: 10px; margin-right: 10px;">Track 14:</label><input name="track14" value="<?php echo $track14; ?>" />
    	<br />
    	<label style="margin-left: 10px; margin-right: 10px;">Artist 15:</label><input name="artist15" value="<?php echo $artist15; ?>" />
    	<label style="margin-left: 10px; margin-right: 10px;">Track 15:</label><input name="track15" value="<?php echo $track15; ?>" />
    	<br />	<br />
    
    	<p>Now Just press the Publish button on the right and your post will be live. </p>
    
    	<p>If you need to back date your post, click the edit next to the publish time (immediately) and change it to when the post needs to be dated for. This date can be in the future, or the past. </p>
    
    	<p>If you just want to make changes, modify the text, and then press 'update' instead of 'publish' on the right and it will be live.</p>
    
    	<p>To preview before posting, hit the save draft button, and then hit the preview button. Your post will popup in a new window or tab depending on browser configuration.</p>
    	<br />
    <?php
    	}
    
    function save_artists(){
    	global $post;
    	update_post_meta($post->ID, "artist1", $_POST["artist1"]);
    	update_post_meta($post->ID, "artist2", $_POST["artist2"]);
    	update_post_meta($post->ID, "artist3", $_POST["artist3"]);
    	update_post_meta($post->ID, "artist4", $_POST["artist4"]);
    	update_post_meta($post->ID, "artist5", $_POST["artist5"]);
    	update_post_meta($post->ID, "artist6", $_POST["artist6"]);
    	update_post_meta($post->ID, "artist7", $_POST["artist7"]);
    	update_post_meta($post->ID, "artist8", $_POST["artist8"]);
    	update_post_meta($post->ID, "artist9", $_POST["artist9"]);
    	update_post_meta($post->ID, "artist10", $_POST["artist10"]);
    	update_post_meta($post->ID, "artist11", $_POST["artist11"]);
    	update_post_meta($post->ID, "artist12", $_POST["artist12"]);
    	update_post_meta($post->ID, "artist13", $_POST["artist13"]);
    	update_post_meta($post->ID, "artist14", $_POST["artist14"]);
    	update_post_meta($post->ID, "artist15", $_POST["artist15"]);
    }
    
    function save_tracks(){
    	global $post;
    	update_post_meta($post->ID, "track1", $_POST["track1"]);
    	update_post_meta($post->ID, "track2", $_POST["track2"]);
    	update_post_meta($post->ID, "track3", $_POST["track3"]);
    	update_post_meta($post->ID, "track4", $_POST["track4"]);
    	update_post_meta($post->ID, "track5", $_POST["track5"]);
    	update_post_meta($post->ID, "track6", $_POST["track6"]);
    	update_post_meta($post->ID, "track7", $_POST["track7"]);
    	update_post_meta($post->ID, "track8", $_POST["track8"]);
    	update_post_meta($post->ID, "track9", $_POST["track9"]);
    	update_post_meta($post->ID, "track10", $_POST["track10"]);
    	update_post_meta($post->ID, "track11", $_POST["track11"]);
    	update_post_meta($post->ID, "track12", $_POST["track12"]);
    	update_post_meta($post->ID, "track13", $_POST["track13"]);
    	update_post_meta($post->ID, "track14", $_POST["track14"]);
    	update_post_meta($post->ID, "track15", $_POST["track15"]);
    }
    
    // only needed for completely custom types
    //register_taxonomy(
    //	"top15tracks",
    //	array(
    //	'top15'
    //	),
    //	array(
    //	'hierarchical' => true,
    //	'label' => "Top 15 Tracks",
    //	'singular_label' => "Top 15",
    //	'rewrite' => true
    //	)
    //
    //	);
    
    // for custom column display in admin interface
    add_filter("manage_edit-top15_columns", "top15_edit_columns");
    add_action("manage_posts_custom_column",  "top15_custom_columns");
    
    function top15_edit_columns($columns){
    		$columns = array(
    			"cb" => "<input type=\"checkbox\" />",
    			"title" => "Top 15 Tracks Date",
    			"artists" => "Artists & Tracks"
    		);
    		return $columns;
    }
    
    function top15_custom_columns($column){
    		global $post;
    		switch ($column)
    		{
    			case "artists":
    				$artist_list = get_post_custom();
    				echo $artist_list["artist1"][0];
    				echo " , ";
    				echo $artist_list["track1"][0];
    				echo "<br />";
    				echo $artist_list["artist2"][0];
    				echo " , ";
    				echo $artist_list["track2"][0];
    				echo "<br />";
    				echo $artist_list["artist3"][0];
    				echo " , ";
    				echo $artist_list["track3"][0];
    				echo "<br />";
    				echo $artist_list["artist4"][0];
    				echo " , ";
    				echo $artist_list["track4"][0];
    				echo "<br />";
    				echo $artist_list["artist5"][0];
    				echo " , ";
    				echo $artist_list["track5"][0];
    				echo "<br />";
    				echo $artist_list["artist6"][0];
    				echo " , ";
    				echo $artist_list["track6"][0];
    				echo "<br />";
    				echo $artist_list["artist7"][0];
    				echo " , ";
    				echo $artist_list["track7"][0];
    				echo "<br />";
    				echo $artist_list["artist8"][0];
    				echo " , ";
    				echo $artist_list["track8"][0];
    				echo "<br />";
    				echo $artist_list["artist9"][0];
    				echo " , ";
    				echo $artist_list["track9"][0];
    				echo "<br />";
    				echo $artist_list["artist10"][0];
    				echo " , ";
    				echo $artist_list["track10"][0];
    				echo "<br />";
    				echo $artist_list["artist11"][0];
    				echo " , ";
    				echo $artist_list["track11"][0];
    				echo "<br />";
    				echo $artist_list["artist12"][0];
    				echo " , ";
    				echo $artist_list["track12"][0];
    				echo "<br />";
    				echo $artist_list["artist13"][0];
    				echo " , ";
    				echo $artist_list["track13"][0];
    				echo "<br />";
    				echo $artist_list["artist14"][0];
    				echo " , ";
    				echo $artist_list["track14"][0];
    				echo "<br />";
    				echo $artist_list["artist15"][0];
    				echo " , ";
    				echo $artist_list["track15"][0];
    				echo "<br />";
    				break;
    		}
    }

    and here is the page used to display the posts;

    <?php
    
    	if (!is_single()) {
    
    		query_posts(array(
    			'post_type' => 'top15', // can be custom post type
    			//'series' => 'top15tracks', // custom taxonomy
    			'paged' => get_query_var( 'paged' ), // set the current page
    			'posts_per_page' => 1 // how many posts on the page?
    		));
    	}
    
    	if (have_posts()):
    		the_post();	
    
    		$custom = get_post_custom($post->ID);
    
    	// artists
    	$artist1 = $custom["artist1"][0];
    	$artist2 = $custom["artist2"][0];
    	$artist3 = $custom["artist3"][0];
    	$artist4 = $custom["artist4"][0];
    	$artist5 = $custom["artist5"][0];
    	$artist6 = $custom["artist6"][0];
    	$artist7 = $custom["artist7"][0];
    	$artist8 = $custom["artist8"][0];
    	$artist9 = $custom["artist9"][0];
    	$artist10 = $custom["artist10"][0];
    	$artist11 = $custom["artist11"][0];
    	$artist12 = $custom["artist12"][0];
    	$artist13 = $custom["artist13"][0];
    	$artist14 = $custom["artist14"][0];
    	$artist15 = $custom["artist15"][0];
    
    	// tracks
    	$track1 = $custom["track1"][0];
    	$track2 = $custom["track2"][0];
    	$track3 = $custom["track3"][0];
    	$track4 = $custom["track4"][0];
    	$track5 = $custom["track5"][0];
    	$track6 = $custom["track6"][0];
    	$track7 = $custom["track7"][0];
    	$track8 = $custom["track8"][0];
    	$track9 = $custom["track9"][0];
    	$track10 = $custom["track10"][0];
    	$track11 = $custom["track11"][0];
    	$track12 = $custom["track12"][0];
    	$track13 = $custom["track13"][0];
    	$track14 = $custom["track14"][0];
    	$track15 = $custom["track15"][0];
    
     ?>
    
    <div <?php post_class() ?> id="post-<?php the_ID(); ?>">
    <div class="entry">
    
    <center><p style="font-weight: bold; font-size: 14px; color: #333333;"><?php the_title(); ?></p></center>
    
    <table class="top15cell" width="95%">
    <tbody>
    <tr>
    <td class="15title">#</td>
    <td class="15title">Artist</td>
    <td class="15title">Track</td>
    </tr>
    <tr>
    <td class="alignRight">1</td>
    <td><?php echo $artist1; ?></td>
    <td><?php echo $track1; ?></td>
    </tr>
    <tr>
    <td class="alignRight">2</td>
    <td><?=$artist2?></td>
    <td><?=$track2?></td>
    </tr>
    <tr>
    <td class="alignRight">3</td>
    <td><?=$artist3?></td>
    <td><?=$track3?></td>
    </tr>
    <tr>
    <td class="alignRight">4</td>
    <td><?=$artist4?></td>
    <td><?=$track4?></td>
    </tr>
    <tr>
    <td class="alignRight">5</td>
    <td><?=$artist5?></td>
    <td><?=$track5?></td>
    </tr>
    <tr>
    <td class="alignRight">6</td>
    <td><?=$artist6?></td>
    <td><?=$track6?></td>
    </tr>
    <tr>
    <td class="alignRight">7</td>
    <td><?=$artist7?></td>
    <td><?=$track7?></td>
    </tr>
    <tr>
    <td class="alignRight">8</td>
    <td><?=$artist8?></td>
    <td><?=$track8?></td>
    </tr>
    <tr>
    <td class="alignRight">9</td>
    <td><?=$artist9?></td>
    <td><?=$track9?></td>
    </tr>
    <tr>
    <td class="alignRight">10</td>
    <td><?=$artist10?></td>
    <td><?=$track10?></td>
    </tr>
    <tr>
    <td class="alignRight">11</td>
    <td><?=$artist11?></td>
    <td><?=$track11?></td>
    </tr>
    <tr>
    <td class="alignRight">12</td>
    <td><?=$artist12?></td>
    <td><?=$track12?></td>
    </tr>
    <tr>
    <td class="alignRight">13</td>
    <td><?=$artist13?></td>
    <td><?=$track13?></td>
    </tr>
    <tr>
    <td class="alignRight">14</td>
    <td><?=$artist14?></td>
    <td><?=$track14?></td>
    </tr>
    <tr>
    <td class="alignRight">15</td>
    <td><?=$artist15?></td>
    <td><?=$track15?></td>
    </tr>
    </tbody>
    </table>
    
    <div class="pager">
    
    	<?php previous_post_link('%link', '<div class="ImagePrev"></div>'); ?>
    	<?php if(!get_adjacent_post(false, '', true)) { echo ''; } ?>
    	<?php next_post_link('%link', '<div class="ImageNext"></div>'); ?>
    	<?php if(!get_adjacent_post(false, '', false)) { echo ''; } ?>
    
    </div>
  • The topic ‘WP 3.1 CUSTOM POST PAGINATION’ is closed to new replies.