WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Paging not working (2 posts)

  1. Danny159
    Member
    Posted 2 years ago #

    Hey guys,

    I am having trouble with my loop...
    I have the following code....

    <?php /* Template Name: Portfolio  */ ?>
    
    <?php get_header(); ?>
    
    <?php
    // Query Out Database
    $wpbp = new WP_Query(array( 'post_type' => 'portfolio', 'posts_per_page' => '1' ) ); 
    
    // Begin The Loop
    if ($wpbp->have_posts()) : while ($wpbp->have_posts()) : $wpbp->the_post();
    ?>
    
    <div class="portfolio">
    <?php if ( (function_exists('has_post_thumbnail')) && (has_post_thumbnail()) ) : ?>
    	<a href="<?php the_permalink(); ?>"><?php the_post_thumbnail('portfolio'); ?></a>
    <?php endif; ?>
    	<div class="portinfo">
        <a href="<?php the_permalink(); ?>"><span><?php echo get_the_title(); ?></span></a>
        <p>Lorem ipsum dolor sit amet consecti un atis al nord di amur. Lorem ipsum dolor sit amet conescti un atis al nord di amur. Lorem ipsum dolor sit amet conescti un atis al nord di amur.</p>
        </div>
    </div>
    
    <?php endwhile; ?>
    <?php else : ?>
    <h2>Not Found</h2>
    <?php endif; ?>
    
    <div class="navigation">
    	<div class="next-posts"><?php next_posts_link('&laquo; Older Entries') ?></div>
    	<div class="prev-posts"><?php previous_posts_link('Newer Entries &raquo;') ?></div>
    </div>
    
    <?php wp_reset_query(); ?>
    <?php get_footer(); ?>

    And I cant get the page navigation to show... it just doesn't seem to want to work... I have 2 posts so it should let me go to previous posts but doesn't?

    Can anyone help?

    Dan

  2. Danny159
    Member
    Posted 2 years ago #

    Ahh fixed, see this guys code:

    <?php
    global $wp_query;
    $paged = get_query_var('paged') ? get_query_var('paged') : 1;
    $args = array(
    	'post_type' => 'CUSTOM_POST_NAME',
    	'product_category' => 'CATEGORY_NAME',
    	'posts_per_page' => 6,
    	'post_status' => 'publish',
    	'orderby' => 'menu_order',
    	'order' => 'DESC',
    	'paged' => $paged
    );
    $wp_query = new WP_Query($args);
    
    while ( $wp_query->have_posts() ) : $wp_query->the_post(); ?>
    	<a href="<?php echo get_permalink(); ?>"><?php the_title(); ?></a>
    <?php endwhile; ?>

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.