331 posts WordPress Theme Devoloper
  • 6 Years of Membership
  • Affiliate Level 1
  • Author Level 9
  • Collector Level 2
+11 more
kayapati
says

I need help please,

I am working on Custom post types ( wordpress 3.0 ) I am getting struck at displaying pagination for the posts.

bellow is my code:

<?php $loop = new WP_Query(array('post_type' ?> 'portfolio', 'orderby'=> 'menu_order', 'paged'=>$paged, 'posts_per_page' =>6)); 
    ?>  

The “next” and “previous” links at the bottom should be displayed after 6 posts, but its not happening.

Any one might be got this problem and got solution.

54 posts
  • Trendsetter
  • Author Level 11
  • Elite Author
  • Top Monthly Author
+8 more
GhostPool
says

Try adding the following before your query:

$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;

I’ve only tried it with a query_posts type query, so I’m not a 100% it will work with yours.

629 posts
  • 5 Years of Membership
  • Affiliate Level 2
  • Collector Level 2
  • Exclusive Author
+4 more
VagrantRadio
says

Haven’t tried it in WP 3 .0 yet, but try this: http://snipplr.com/view/32185/wordpress-paginated-wpquery/

331 posts WordPress Theme Devoloper
  • 6 Years of Membership
  • Affiliate Level 1
  • Author Level 9
  • Collector Level 2
+11 more
kayapati
says
Try adding the following before your query:
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
I’ve only tried it with a query_posts type query, so I’m not a 100% it will work with yours.

I tired it, it is not working.

331 posts WordPress Theme Devoloper
  • 6 Years of Membership
  • Affiliate Level 1
  • Author Level 9
  • Collector Level 2
+11 more
kayapati
says
Haven’t tried it in WP 3 .0 yet, but try this: http://snipplr.com/view/32185/wordpress-paginated-wpquery/

This is too I tried but no luck.

331 posts WordPress Theme Devoloper
  • 6 Years of Membership
  • Affiliate Level 1
  • Author Level 9
  • Collector Level 2
+11 more
kayapati
says

This is my portfolio page code, please help if any one have an idea what goes wrong.


<?php /* Template Name: Portfolio  page */
get_header(); ?>
<div id="main-container">
<!-- ***************************************************Middle Section***************************************************************  -->
  <div id="content-column-wide">

            <?php $loop = new WP_Query(array('post_type' ?> 'portfolio', 'orderby'=> 'menu_order', 'paged'=>$paged, 'posts_per_page' =>2)); 

          ?> 

    <?php while ( $loop?>have_posts() ) : $loop->the_post(); ?>

   <ul class="portfolio-box">
       <li>
        <h2><?php the_title(); ?></h2> 
        <a href="<?php echo $website_url ?>"><?php the_post_thumbnail(); ?> </a>        
    <?php $img=get_post_meta($post?>ID, 'Image', true); 

                $timthumboption = get_option("timthumboption"); ?>

        <?php if($img) { ?>

        <?php if( $timthumboption == "0" ){?>

                        <a href="<?php the_permalink() ?>">    <img src="<?php bloginfo('template_url'); ?>/timthumb.php?src=<?php echo $img; ?>            

            &amp;w=255&amp;h=170&amp;zc=2" alt="<?php the_title(); ?>" /> </a>

                                <?php } ?>

                                <?php if( $timthumboption == "1" ){?>

                                <a href="<?php the_permalink() ?>"><img src="<?php echo $img; ?>" height="170" alt="<?php the_title(); ?>" width="275" /></a>

                            <?php }?>

                              <?php } else { ?>
                            <a href="<?php the_permalink() ?>"><img title="<?php the_content_rss('', TRUE, '', 20); ?>" src="<?php bloginfo('template_url'); ?>/images/portfolio-default.jpg" height="170" alt="no image" width="255" /></a>
        <?php } ?>
        <br />  <br />
        <?php the_content_rss('', TRUE, '', 20); ?>

        <a href="<?php the_permalink() ?>" class="view-more"> <img src="<?php bloginfo('template_url'); ?>/images/view-more.png" alt="view more" /> </a>
        </li>
    </ul>
        <?php endwhile; ?> 

         <div class="navigation1">
          <div class="alignleft"><?php next_posts_link('« Older Entries') ?></div>
          <div class="alignright"><?php previous_posts_link('Newer Entries »') ?></div>
        </div>

        </div>       

<!-- ***************************************************End class="container_16"**************************************************************  -->

<?php get_footer(); ?>

</div>
461 posts Don't be a HATER!
  • Weekly Top Seller
  • Elite Author
  • Author Level 8
  • Featured Author
+6 more
CodeElite
says

Try this mate, use caller_get_posts and reset the wp query after looping :)

$args=array(
    'post_type'         => 'portfolio',
    'post_status'        => 'publish',
    'orderby'                    => 'menu_order',
        'posts_per_page'         =>6
    'caller_get_posts'            =>1,
    'paged'            =>$paged,
    );
query_posts($args);
while (have_posts()): the_post();

    //loop code here

endwhile;

//pagination code here

wp_reset_query();

hope this help,

good luck :)

331 posts WordPress Theme Devoloper
  • 6 Years of Membership
  • Affiliate Level 1
  • Author Level 9
  • Collector Level 2
+11 more
kayapati
says
Try this mate, use caller_get_posts and reset the wp query after looping :)
$args=array(
    'post_type'         => 'portfolio',
    'post_status'        => 'publish',
    'orderby'                    => 'menu_order',
        'posts_per_page'         =>6
    'caller_get_posts'            =>1,
    'paged'            =>$paged,
    );
query_posts($args);
while (have_posts()): the_post();

    //loop code here

endwhile;

//pagination code here

wp_reset_query();

hope this help,

good luck :)

Thanks themesguy :)

331 posts WordPress Theme Devoloper
  • 6 Years of Membership
  • Affiliate Level 1
  • Author Level 9
  • Collector Level 2
+11 more
kayapati
says

the bellow code works for me:

<?php query_posts(array(
            'post_type' ?> 'portfolio', // can be custom post type
            'orderby'=> 'menu_order',
            'paged'=>$paged, 

        ));

        ?>

we can adjust the number of post to be displayed in wp admin dash board settings > reading.

Thanks friends for your help.

186 posts
  • Power Elite Author
  • 6 Years of Membership
  • Author Level 12
  • Trendsetter
+7 more
stmcan
says
the bellow code works for me:
<?php query_posts(array(
            'post_type' ?> 'portfolio', // can be custom post type
            'orderby'=> 'menu_order',
            'paged'=>$paged, 

        ));

        ?>

we can adjust the number of post to be displayed in wp admin dash board settings > reading.

Thanks friends for your help.

I’ve just stocked in same point. What if people want to show 6 posts on their portfolio page but 10 posts on blog page. With your solution they need to use same listing number for these two pages. In my case I’ve products, photos, portfolio(s) and blog and i want to let the user choose different listing numbers for the parts of theme. We have to find another solution mate :(

by
by
by
by
by
by