ThemeShaper Forums » Thematic

[closed]

No navigation below custom post_type loop

(7 posts)
  • Started 3 years ago by JC
  • Latest reply from dylancoyne
  • This topic is resolved
  1. JC
    Member

    This has been driving me nuts...
    I have this template in a page just to display custom post_types on it :

    <?php
    /*
    Template Name: Art&iacute;culos
    .
    .
    */
    ?>
    <?php
        // calling the header.php
        get_header();?>
    
    	<div id="container">
    	<div id="content">
                  <?php $loop = new WP_Query( array( 'post_type' => 'articulos') ); ?>
    				<?php while ( $loop->have_posts() ) : $loop->the_post(); ?>
                    <div id="post-<?php the_ID() ?>" class="<?php thematic_post_class() ?>">
                    <a href="<?php the_permalink() ?>"><?php the_post_thumbnail();  // we just called for the thumbnail ?></a>
        			<h3 class="entry-title"><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h3>
    				<?php the_excerpt(); ?>
    				<?php thematic_postfooter(); ?>
    					<?php	thematic_nav_below(); ?>
    			</div><!-- .post -->
                  <?php endwhile; ?>
    	</div><!-- #content -->
    	</div><!-- #container -->
    
    <?php
    	get_sidebar();
    
        // calling the standard sidebar
        thematic_sidebar();
    
        // calling footer.php
        get_footer();
    
    ?>

    Te fact is that this custom loop works allright, but I don't get the navigation after the post (as the one I get in the home page)
    I don't know how to modify this code to make it happen.

    I am really grateful for the support I've been receiving so far,
    Thank you .

    Posted 3 years ago #
  2. Hi JC,

    Try this. I think you'll need the global $wp_query to enable pagenation.

    <div id="container">
    		<div id="content">
    
    			<?php $wp_query = null; ?>
    			<?php $wp_query = new WP_Query('post_type=articulos&posts_per_page=4&paged='.$paged ); ?>
    			<?php while ( $wp_query->have_posts() ) : $wp_query->the_post(); ?>
    
                            <div id="post-<?php the_ID() ?>" class="<?php thematic_post_class() ?>">
    				<a href="<?php the_permalink() ?>"></a>
    	    		        <h3 class="entry-title"><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h3>
    				<?php the_excerpt(); ?>
    				<?php thematic_postfooter(); ?>
    			</div><!-- .post -->
    
    			<?php endwhile; ?>
    			<?php	thematic_nav_below(); ?>
    
    		</div><!-- #content -->
    </div><!-- #container -->

    That should work better to demonstrate pagenation for a custom post type
    - Gene

    Posted 3 years ago #
  3. JC
    Member

    Thank you so much em hr !!
    This is fantastic ! , it works as you expected it .

    Posted 3 years ago #
  4. JC
    Member

    UPDATE:
    As I said the code you provided works beautifully , but I had tested it locally (MAMP) only. Unfortunately when I uploaded it to the live server and I click on "older posts" I get a NOT FOUND 404 page ??.

    I repeat it works ok on my local install, any ideas about this ?

    Thank you.

    Posted 3 years ago #
  5. I'm not sure what is going on. It sounds like a permalinks issue. Try updating your permalinks from the admin on the live site also check and see if you have a proper .htaccess file installed.

    Other than that I'd be looking for general differences in the versions of WP and the code used to register the custom post type between the two set ups.

    Good luck-
    Gene

    Posted 3 years ago #
  6. JC
    Member

    Well it seems that AFTER creating your custom taxonomy you need to visit the Permalinks settings page because it flushes the rewrite rules. Just doing this solved my problem.
    Seen here : http://core.trac.wordpress.org/ticket/13022

    Thank you em hr for putting me on the way of searching for permalinks issues with taxonomies (and custom post_types by the way)

    Posted 3 years ago #
  7. Hi em hr,

    I am having a similar problem with a custom post type for a page template. the code below doesn't return any posts. As soon a s I remove the line $wp_query = null I get my list of post but with no pagination.

    Any help would be appreciated.

    
    <div id="container">
      <div id="content">
    
      <div id="opinion">
    <?php $wp_query = null; ?>
    
    <?php
    //trying to get page navigation below to work here but with not much success
    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    
    		  $args = array(
    	'meta_key'=> creative_comments,
        'meta_value'=> yes,
    	'paged'=>$paged,
    	'posts_per_page'=>3,
    
     );
    
    //query_posts($args);
    	$my_query = new WP_Query($args);
    while ($my_query->have_posts()) : $my_query->the_post();?>
    
             <div id="post-<?php the_ID() ?>" class="<?php thematic_post_class() ?>">
              <?php thematic_postheader(); ?>
    
               <div class="entry-content">
                     <?php thematic_content(); ?>
                     <?php wp_link_pages('before=<div class="page-link">' .__('Pages:', 'thematic') . '&after=</div>') ?>
    
                </div>
                <?php thematic_postfooter(); ?>
              </div><!-- .post -->
              <?php endwhile; ?>
                   <?php thematic_nav_below(); ?>
    
            </div><!-- #opinion -->
      </div><!-- #content -->
    </div><!-- #container -->
    
    
    Posted 3 years ago #

RSS feed for this topic

Topic Closed

This topic has been closed to new replies.