264 posts WordPress Theme Devoloper
  • Has been part of the Envato Community for over 6 years
  • Has referred 1+ members
  • Has sold $250,000+ on Envato Market
  • Has collected 10+ items on Envato Market
+6 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
  • Has referred 500+ members
  • Has sold $750,000+ on Envato Market
  • Has collected 100+ items on Envato Market
  • Elite Author: Sold more than $75,000 on Envato Market
+5 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
  • Has been part of the Envato Community for over 4 years
  • Has referred 10+ members
  • Has collected 10+ items on Envato Market
  • Sells items exclusively on Envato Market
+2 more
VagrantRadio says

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

264 posts WordPress Theme Devoloper
  • Has been part of the Envato Community for over 6 years
  • Has referred 1+ members
  • Has sold $250,000+ on Envato Market
  • Has collected 10+ items on Envato Market
+6 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.

264 posts WordPress Theme Devoloper
  • Has been part of the Envato Community for over 6 years
  • Has referred 1+ members
  • Has sold $250,000+ on Envato Market
  • Has collected 10+ items on Envato Market
+6 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.

264 posts WordPress Theme Devoloper
  • Has been part of the Envato Community for over 6 years
  • Has referred 1+ members
  • Has sold $250,000+ on Envato Market
  • Has collected 10+ items on Envato Market
+6 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>
448 posts Don't be a HATER!
  • Has referred 10+ members
  • Has sold $125,000+ on Envato Market
  • Has collected 10+ items on Envato Market
  • Sells items exclusively on Envato Market
+5 more
webinpixels 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 :)

264 posts WordPress Theme Devoloper
  • Has been part of the Envato Community for over 6 years
  • Has referred 1+ members
  • Has sold $250,000+ on Envato Market
  • Has collected 10+ items on Envato Market
+6 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 :)

264 posts WordPress Theme Devoloper
  • Has been part of the Envato Community for over 6 years
  • Has referred 1+ members
  • Has sold $250,000+ on Envato Market
  • Has collected 10+ items on Envato Market
+6 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.

170 posts
  • Power Elite Author: Sold more than $1M on Envato Market
  • Has been part of the Envato Community for over 5 years
  • Sells items exclusively on Envato Market
  • Made it to the Authors' Hall of Fame
+4 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