245 posts WordPress Theme Devoloper
  • Author had a Free File of the Month
  • Bought between 10 and 49 items
  • Elite Author
  • Exclusive Author
  • Has been a member for 5-6 years
  • Most Wanted Bounty Winner
  • Referred between 1 and 9 users
  • Repeatedly Helped protect Envato Marketplaces against copyright violations
+1 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
  • Elite Author
  • Sold between 250 000 and 1 000 000 dollars
  • Has been a member for 4-5 years
  • United Kingdom
  • Referred between 500 and 999 users
  • Bought between 100 and 499 items
  • Exclusive Author
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
  • Bought between 10 and 49 items
  • Exclusive Author
  • Has been a member for 4-5 years
  • Referred between 10 and 49 users
  • Repeatedly Helped protect Envato Marketplaces against copyright violations
  • United States
VagrantRadio says

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

245 posts WordPress Theme Devoloper
  • Author had a Free File of the Month
  • Bought between 10 and 49 items
  • Elite Author
  • Exclusive Author
  • Has been a member for 5-6 years
  • Most Wanted Bounty Winner
  • Referred between 1 and 9 users
  • Repeatedly Helped protect Envato Marketplaces against copyright violations
+1 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.

245 posts WordPress Theme Devoloper
  • Author had a Free File of the Month
  • Bought between 10 and 49 items
  • Elite Author
  • Exclusive Author
  • Has been a member for 5-6 years
  • Most Wanted Bounty Winner
  • Referred between 1 and 9 users
  • Repeatedly Helped protect Envato Marketplaces against copyright violations
+1 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.

245 posts WordPress Theme Devoloper
  • Author had a Free File of the Month
  • Bought between 10 and 49 items
  • Elite Author
  • Exclusive Author
  • Has been a member for 5-6 years
  • Most Wanted Bounty Winner
  • Referred between 1 and 9 users
  • Repeatedly Helped protect Envato Marketplaces against copyright violations
+1 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>
438 posts Don't be a HATER!
  • Exclusive Author
  • Elite Author
  • Sold between 100 000 and 250 000 dollars
  • Bought between 10 and 49 items
  • Referred between 10 and 49 users
  • Won a Competition
  • Repeatedly Helped protect Envato Marketplaces against copyright violations
  • Has been a member for 4-5 years
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 :)

245 posts WordPress Theme Devoloper
  • Author had a Free File of the Month
  • Bought between 10 and 49 items
  • Elite Author
  • Exclusive Author
  • Has been a member for 5-6 years
  • Most Wanted Bounty Winner
  • Referred between 1 and 9 users
  • Repeatedly Helped protect Envato Marketplaces against copyright violations
+1 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 :)

245 posts WordPress Theme Devoloper
  • Author had a Free File of the Month
  • Bought between 10 and 49 items
  • Elite Author
  • Exclusive Author
  • Has been a member for 5-6 years
  • Most Wanted Bounty Winner
  • Referred between 1 and 9 users
  • Repeatedly Helped protect Envato Marketplaces against copyright violations
+1 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.

160 posts
  • Power Elite Author
  • Power Elite Author: Sold between 1 000 000 - 1 999 999 dollars
  • Exclusive Author
  • Has been a member for 5-6 years
  • Bought between 100 and 499 items
  • Referred between 500 and 999 users
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