WordPress.org

Ready to get started?Download WordPress

Forums

WP-PageNavi not working properly on custom pages (3 posts)

  1. clestcruz
    Member
    Posted 1 year ago #

    I have created a custom page that will display posts only from a specific category and i have also set wordpress to show only 4 number of post. Now the problem is the "WP-PageNavi" is not working properly. Here is the code.

    [please mark any posted code - http://codex.wordpress.org/Forum_Welcome#Posting_Code ]

    <div class="sixteen columns latest_post">
    
    <?php query_posts('cat=3', 'posts_per_page=-1=-'); if(have_posts()) : while(have_posts()) :the_post(); ?>
           <div class="sixteen columns alpha omega outer_box">
               <div class="inner_box articles">
    
                   <!--TITLE OF THE POST -->
                   <h3 class="post-title"><a>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h3>
    
    			   <ul class="data">
    
    <li><?php the_author_posts_link() ?> /</li>
    <li><?php the_category(', ') ?> /</li>
    <li><?php the_time('F jS, Y') ?> /</li>
    <li><?php comments_number() ?></li>
                   <hr>
    
    			   <!--THUMBNAIL -->
    			   <div class="align_thumbnail_right">
    		          <?php if ( has_post_thumbnail()) the_post_thumbnail('home-thumb'); ?>
    
    			   </div>
    
    			   <div class="content">
                      <!--TEXT -->
                      <?php the_excerpt(); ?>
    
                     <a>"><span>Read More</span></a>
                   </div>
    
                </div>
    
           </div>
    
    <?php endwhile; endif; >
    
    <div class="pagination">
    <?php wp_pagenavi(); ?>
    </div>
    
    </div>

    I applied the plugin on the index and it seems to be working fine. But when i tried it on a custom page it doesn't work. Really hope that someone can help me here since i'm not really good at PHP

  2. alchymyth
    The Sweeper & Moderator
    Posted 1 year ago #

    generally review http://codex.wordpress.org/Pagination

    also check http://codex.wordpress.org/Function_Reference/query_posts

    for example, try to change this line:

    query_posts('cat=3', 'posts_per_page=-1=-');

    to proper syntax and include the 'paged' parameter:

    query_posts('cat=3&posts_per_page=-1&paged='.get_query_var('paged'));

    i have also set wordpress to show only 4 number of post

    be aware that posts_per_page=-1 calls all posts; try to change it to posts_per_page=4

  3. clestcruz
    Member
    Posted 1 year ago #

    I tried reviewing the codex earlier before posting but really have a hard time since i'm not good in coding PHP.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags