• Resolved Roy

    (@gangleri)


    I have created a template that displays custom post types based on the index.php of my theme. Then I created a page to which I assigned that template. This works fine except for the fact that the “previous” and “next” links do not work and I don’t know why. The links are correct (/page/2), but the same posts are loaded. Could anyone tell me if this is because of a mistake in the template? The template can be seen here. I later replaced the loop that you see there to set the number of displayed posts to 100 so that navigation is not needed, so the template currently uses:

    <?php
    $args = array(
    	'posts_per_page' => 100,
    	'post_type' => 'blog'
    );
    query_posts($args);
    if ( have_posts() ) : while ( have_posts() ) : the_post();
    ?>

Viewing 14 replies - 16 through 29 (of 29 total)
  • https://net.tutsplus.com/tutorials/wordpress/introducing-wordpress-3-custom-taxonomies/

    I used that for my custom taxonomies, just knowing that here:
    register_taxonomy( 'operating_system', 'post', array

    instead of post, I used ve_products since that was my custom post type, that way the new taxonomy menu is on the custom post type page

    And, the more tag was this bit of code I accidentally gave you earlier

    <?php
    global $more;
    $more = 0;
    ?>
    
    			<?php the_content('<span class="details">Additional Details</span>'); ?>

    basically that is needed whenever you use a page and want to use the more tag

    So if you use a page template to display your custom post types like I do, you would need that for the more to work

    Thread Starter Roy

    (@gangleri)

    That works perfectly Rev! Thanks again. It took a while before I could try.
    The plugin that I use can make custom taxonomies perfectly, but just as with these other things, they don’t work. When I make a custom post type ‘quotes’ and a custom taxonomy ‘from’ and I asign the taxonomy ‘dumezil’ to a quote, the link of the custom taxonomy will not be website/quotes/from/dumezil, but website/dumezil and that (of course) doesn’t work well.

    [edit] Just forget about the taxonomies. I managed to use them similar to categories and tags, but not anymore. There are things above this point on the priority list.

    Would one of you guys mind summarizing the changes that you made to create Next/Prev links? It’s a little hard to follow the thread completely.

    I’m having a similar issue: I have a CPT with a custom taxonomy. The taxonomy terms show up in a menu that I created, but clicking on the terms in the menu displays an archive of that term. And there’s no way to really navigate through the posts that I can figure out.

    I’d appreciate any help.

    does the template you are using have a previous and next post link?

    something like:

    <div class="alignleft"><?php next_posts_link(__('&laquo; Older Entries')) ?></div>
    			<div class="alignright"><?php previous_posts_link(__('Newer Entries &raquo;')) ?></div>

    Yup. This is what I’m using:

    <div class="nav-previous"><?php next_posts_link(__('<span class="meta-nav">&laquo;</span> Previous item', 'thematic')) ?></div>
    				<div class="nav-next"><?php previous_posts_link(__('Next item <span class="meta-nav">&raquo;</span>', 'thematic')) ?></div>

    It’s a thematic child theme.

    ah…I know nothing about thematic.

    That code should work as long as its in the proper location. mine’s above the comment form, above the endwhile

    Not sure what sort of options menu that theme has….like if there is an option to turn off pagination

    Also, not trying to be a smart ass or anything, just to be sure, you’re looking at the right template for an archive page?

    Ha! No, I appreciate the comment re: the archive page. I created a “taxonomy-type.php” file, and checked that it is, indeed, being used on the page (echoed a string).

    When you say “above the endwhile”, do you mean still in the main post loop? If that’s the case, the link to “Older items” shows up, but clicking on it brings me to a 404 page.

    Also, this is what my loop looks like (in case that matters):

    query_posts( array( 'post_type' => 'portfolio', 'showposts' => 1 ) );
                if ( have_posts() ) : while ( have_posts() ) : the_post();
                	the_content();
                thematic_navigation_below();
                endwhile;
                endif;

    I need to pay attention to what people type a little more! lol

    on pages and single, the next_post_link is above the endwhile on my theme

    on posts pages, such as on my taxonomy page, the navigation is between the endwhile and endif

    Also, your query needs to include pagination, thats what we were talking about above

    <?php $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; query_posts(array(
    	'post_type' => 'portfolio', // custom post type
             'showposts' => 1,
             'paged'=>$paged,
            ));
    ?>

    Here’s what’s happening:

    I get a link to “Older items”, which seems good. That links to “SITEURL/TAXONOMY/TAXONOMY_TERM/page/2/” (caps=generic structure)

    When I click the link, I get the 404.

    My loop looks like:

    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; query_posts(array(
    				'post_type' => 'portfolio', // custom post type
    				 'showposts' => 1,
    				 'paged'=>$paged,
    				));
                if ( have_posts() ) : while ( have_posts() ) : the_post();
                	the_content();
                endwhile;
                thematic_navigation_below();
                endif;

    Does it matter how I registered my CPT? They are not hierarchical.

    I had a few quirks with pagination at first when I set things up like you have

    resaved my functions.php

    I reset my permalinks (save to default, back to custom)

    and that fixed my problems. But your code looks good as does your structure… everything looks pretty much like mine

    Bummer. Still not working.

    Oh well, thanks for the help! CPT could use a little more thorough documentation, if you ask me. I’ll let you know if I get it working.

    Ok, here’s what I think is the crux of the issue:

    I have a menu that lists all of the terms of a taxonomy. If I click on the term name, I go to a page that is an archive of that term and lists all of the posts labeled with that term. There is no navigation, because I’m looking at an archive. If I click on a post’s permalink, I go to the post’s page (ie. single.php), and now have the Next and Prev links.

    What I don’t know how to do is: click on the taxonomy term in the menu, and just have it display the first post labeled with that term, in a non-archive format. Essentially, it should use single.php instead of archive.php, or something to that effect.

    Does that make sense?

    (I’ve switched to Twentyten theme to test this, just editing functions.php to add the post types and taxonomies.)

    you said you are using taxonomy-type.php right? Thats exactly what I use. When I click on my term, it goes to an archive page of posts with that term, with pagination working properly, using the taxonomy-type.php file

    if you click on a term, you will always get an archive page….but with your query you should be able to get it to behave like a single.php type page

    As long as that taxonomy-term.php file has navigation in it , it should work

Viewing 14 replies - 16 through 29 (of 29 total)
  • The topic ‘Previous Custom Post Types’ is closed to new replies.