$20
404 on Custom Post Type Taxonomy page
Here's the code in my functions file:
// REGISTER CUSTOM POST TYPE FOR EDUCATION LIBRARY
function education_library_post_type() {
register_post_type('education-library',array(
'labels' => array(
'name' => 'Education Library',
'singular_name' => 'Article',
'menu_name' => 'Education Library',
'add_new_item' => __('Add New Article'),
'edit' => __('Edit'),
'edit_item' => __('Edit Article'),
'new_item' => __('New Article'),
'view' => __('View Article'),
'view_item' => __('View Article'),
'search_items' => __('Search Articles'),
'not_found' => __('No Articles found'),
'not_found_in_trash' => __('No Articles found in Trash'),
),
'public' => true,
'show_ui' => true,
'show_in_menu' => true,
'supports' => array('title','editor','thumbnail', 'custom-fields'),
'menu_position' => 25,
'rewrite' => array(
'slug' => 'education-library',
'with_front' => false
),
'capability_type' => 'post',
'hierarchical' => false,
'query_var' => true,
'has_archive' => 'post',
));
}
add_action('init', 'education_library_post_type', 0);
// CREATE TAXONOMY CAPABILITY FOR EDUCATION LIBRARY
function create_education_library_taxonomies() {
register_taxonomy('education-library-category', 'education-library', array(
'hierarchical' => true,
'label' => 'Library Categories',
'query_var' => true,
'public' => true,
'rewrite' => array(
'slug' => 'education-library-category',
'with_front' => false
),
)
);
}
add_action('init', 'create_education_library_taxonomies', 0);And here's the code for my template file:
<section id="content" class="posts group floatleft">
<?php global $wp_query; ?>
<?php $args = array_merge( $wp_query->query, array( 'posts_per_page' => '1' ) ); ?>
<?php query_posts($args); ?>
<?php if (have_posts()) : ?>
<?php if (function_exists('dynamic_sidebar') && dynamic_sidebar('Video Library Filter')) : ?>
<?php endif; ?>
<h2><?php single_cat_title(); ?></h2>
<?php while (have_posts()) : the_post(); ?>
<article class="posts library-posts group">
<?php if ( has_post_thumbnail() ) : ?>
<div class="post-thumb group">
<?php the_post_thumbnail('large'); ?>
</div><!-- thumb -->
<?php else : ?>
<div class="post-thumb group">
<img src="<?php bloginfo('template_url') ?>/images/no-image-195x130.jpg" alt="no-image-195x130" width="195" height="130" />
</div><!-- thumb -->
<? endif; ?>
<h3 class="post-hd">
<a class="more-link" title="Link to <?php the_title(); ?>" href="<?php the_permalink(); ?>">
<?php the_title(); ?>
</a>
</h3>
<div class="meta">
<span class="post-author">
written by <a title="View all posts by <?php the_author_meta('display_name'); ?>" href="<?php the_author(); ?>"><?php the_author_meta('first_name'); ?></a>
</span>
<span class="meta-sep">|</span>
<span class="post-date"><?php the_time('F jS, Y') ?></span>
</div><!-- meta -->
<div class="entry group">
<?php the_excerpt(); ?>
<a class="more-link" title="Link to <?php the_title(); ?>" href="<?php the_permalink(); ?>">
read full article ›
</a>
</div><!-- entry -->
</article><!-- post-ID -->
<?php endwhile; ?>
<nav class="posts-nav">
<div class="prev-posts btn"><?php next_posts_link('Older Entries') ?></div>
<div class="next-posts btn"><?php previous_posts_link('Newer Newer') ?></div>
</nav><!-- posts-nav -->
<?php else : ?>
<article id="not-found" class="group">
<?php if (function_exists('dynamic_sidebar') && dynamic_sidebar('Class Schedule Filter')) : ?>
<?php endif; ?>
<h2>Nothing Found</h2>
<p>There are currently no posts assigned to this category.</p>
</article><!-- not-found -->
<?php endif; ?>
</section><!-- content -->The trouble I'm having is with the next_posts_link. When I click it I get the 404 page as opposed to the previous post.
Here's a link to the page: http://baseline.snapsize.com/education-library-category/video-library
Thanks for the help.
Denis Leblanc | 07/11/11 at 8:31pm
| Edit
(5) Possible Answers Submitted...
-

Last edited:
07/11/11
8:49pmChuck Wilson says:Do you have more than one post yet? I've had experiences before where I was showing 8 posts per page, and the default in settings was set to 10, when trying to go to the next page it 404ed because there wasn't 10 more posts, since you only are showing one post at a time I wonder if this could be an issue.
You could also try this plugin which I've used in the past to fix similar issues. http://wordpress.org/extend/plugins/custom-post-type-category-pagination-fix/
Another (possibly less desirable) solution is to set your default number of posts to show to 1.
In WP Admin Settings/Reading/Blog pages show at mostPrevious versions of this answer: 07/11/11 at 8:49pm
- 07/11/11 8:53pm
Denis Leblanc says:No luck. Installed the plugin, revisited the permalink settings page and still get the 404 page.
I'd like to avoid extra plugins unless I really need them.
Thanks for trying.
d. - 07/11/11 9:04pm
Chuck Wilson says:Denis, I've got one more trick to try.
replace,
<?php next_posts_link('Older Entries') ?>
<?php previous_posts_link('Newer Newer') ?>
with
<?php previous_posts_link('Older Entries') ?>
<?php next_posts_link('Newer Newer', $loop->max_num_pages) ?>
and
<?php global $wp_query; ?>
<?php $args = array_merge( $wp_query->query, array( 'posts_per_page' => '1' ) ); ?>
<?php query_posts($args); ?>
with
<?php
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
query_posts($query_string .'&posts_per_page=1&paged=' . $paged);?>
If that doesn't work I'm out of ideas, good luck.
- 07/11/11 10:07pm
Denis Leblanc says:No luck with that either. Thanks for the help.
d.
- 07/11/11 8:53pm
-

Last edited:
07/11/11
8:55pmMaor Barazany says:You may want to check the nextprevious-post-link-plus plugin that can help you achieve full support for cpt's and single navigation.
That solution has been helpful also on another question here
You may also try to re-save your permalink structure.
Previous versions of this answer: 07/11/11 at 8:55pm
- 07/11/11 9:02pm
Denis Leblanc says:Maor,
I'd really like to stay away from using any more plugins on this website, it's already a beast to begin with. I can't see this being a big issue, I'm just tired of staring at this bit.
Thanks.
d. - 07/11/11 9:19pm
Maor Barazany says:This post might help you too.
- 07/11/11 10:09pm
Denis Leblanc says:Maor,
That didn't help either. Basically the same solution as Chuck's above and neither worked.
Have you guys looked at my function creating the post type and taxonomy? Perhaps I missed something there.
d. - 07/11/11 10:20pm
Maor Barazany says:A.
In your register_post_type function, try to change-
'has_archive' => 'post',
to
'has_archive' => true,
It thinks that your CPT's archive page is the posts's archive, it may be there.
After you do this, re-save your permalink structure again.
B.
What is the file name of your template file you use? - 07/11/11 10:27pm
Maor Barazany says:If it is not working, try to change for the test the name of your custom taxonomy to something else, it might be that the prefix of names the same, it might cause errors some times.
Also, in your register_taxonomy function, change the query_var parameter to be a string and not true -
'query_var' => 'education-library-category',
After these changes of course re-save your permalinks. - 07/12/11 12:18am
Denis Leblanc says:This is driving me nuts. Can't get anything to work. I will rename my custom taxonomy in the morning and see what I get.
Thanks for your help.
d.
- 07/11/11 9:02pm
-

Last edited:
07/12/11
9:10amErez S says:This question is the same as yours:
http://wpquestions.com/question/show/id/2184
Try the solutions there- 07/12/11 1:24pm
Denis Leblanc says:There was no solution there. It got handled privately and the answer never got shared.
By the sounds of it, custom post types and custom taxonomies aren't advanced enough yet to be able to handle modifying the query. - 07/12/11 1:28pm
Erez S says:So contact the expert/asker and ask him what was the solution.
- 07/12/11 1:24pm
-

Last edited:
07/14/11
3:38am -

Last edited:
07/14/11
5:30pmLucas Wynne says:This WILL work, I'm 100% sure... you might need somebody else to add to this answer for you as my time is limited, but you can always split the money how you see fit...
Use this instead of your current code, replace "NUMBER" with the appropriate numbers:
<?php
query_posts('cat=NUMBER&posts_per_page=NUMBER&paged='.$paged);
if (have_posts()) :
?>
<?php while (have_posts()) : the_post(); ?>
<?php endwhile: ?>
<?php endif; ?>
This question has expired.
Current status of this question: Community pot





