• Resolved harrismc

    (@harrismc)


    <?php get_header(); ?>
    
    <div class="maincontent">
    		<div class="contentleft">
    
    			<?php if (have_posts()) : ?>
    <?php query_posts('posts_per_page=3');
    $do_not_duplicate = array();
    while (have_posts()) : the_post();
    $do_not_duplicate[] = $post->ID;
    ?>
    
    			<div class="post">
    				<div class="posttitle"><h1><a href="<?php the_permalink() ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a></h1></div>
    				<div class="datebox"><p><span><?php the_time('F j, Y') ?></span> | <?php comments_popup_link('No Comments', '1 Comments', '% Comments'); ?></p></div>
    				<div class="postcontent">
    					<?php the_content('Read the rest of this entry &raquo;'); ?>
    					<iframe src="http://www.facebook.com/plugins/like.php?href=<?php echo urlencode(get_permalink($post->ID)); ?>&layout=standard&show-faces=true&width=500&action=like&colorscheme=light" scrolling="no" frameborder="0" allowTransparency="true" style="border:none; overflow:hidden; width:500px; height:60px"></iframe>
    					<div class="commentslink"><p><?php comments_popup_link('No Comments', '1 Comments', '% Comments'); ?> | <a href="<?php the_permalink() ?>">Leave a comment</a></p></div>
    
    					<div class="tagbox">
    						<p>Tagged As | <?php the_tags(__(''), ', ', ''); ?></p>
    					</div>
    				</div>
    			</div>
    			<?php endwhile; ?>
    			<?php else : ?>
    			<h2 class="center">Not Found</h2>
    			<p class="center">Sorry, but you are looking for something that isn't here.</p>
    		   <?php endif; ?>
    
    <div id="bottomposts">
     <?php if (have_posts()) : ?>
    <?php rewind_posts(); ?>
    <?php 
    
    query_posts('posts_per_page=11');
    
    while (have_posts()) : the_post(); update_post_caches($posts);
    if ( !in_array( $post->ID, $do_not_duplicate ) ):
    ?>
    <div class="postovi">
     <h2><a href="<?php the_permalink(); ?>" id="post-<?php the_ID(); ?>"><?php the_title(); ?></a></h2>
    <?php echo excerpt(55); ?><p></p>
    <a href="<?php the_permalink(); ?>" id="post-<?php the_ID(); ?>">Read more...</a>
    </div>
    <?php endif; ?>
    <?php endwhile; ?>
    			<?php else : ?>
    			<h2 class="center">Not Found</h2>
    			<p class="center">Sorry, but you are looking for something that isn't here.</p>
    		   <?php endif; ?>
    </div>
    
    <div class="pagination">
    				<div class="previous"><?php previous_posts_link('Previous Entries') ?></div>
    				<div class="next"><?php next_posts_link('Next Entries') ?></div>
    			</div>
    		</div>
    		<div class="contentright">
    			<?php get_sidebar(); ?>
    		</div>
    	</div>
    
    <?php get_footer(); ?>

    I am having problem with navigation, i use 2 loops in 1st i display 3 recent posts , and in the next one i display 8 short text posts
    but my page navigation doesnt work, allways showing same posts

Viewing 15 replies - 1 through 15 (of 21 total)
  • Thread Starter harrismc

    (@harrismc)

    query_posts(‘posts_per_page=11’); in this line i added 11 becouse when i filter these from first loop only displaying 5
    Well just to save time it might be helpful… πŸ™‚

    searching for ‘query_posts paged’ should give you some info

    Alchy. I suggest you search for it. I have just read for 25 minutes trying to get that to work on my WordPress, and it has not been constructive for my learning, or me… hehehhe. *headache*

    Could me and above person have a little more information?

    Thanks though!

    Thread Starter harrismc

    (@harrismc)

    I have reached 4 hours πŸ˜€ still no clue
    but I found this site, but i dont get it πŸ˜€

    http://stylizedweb.com/2008/08/13/query_posts-pagination-problem/

    Don’t worry about that site.

    The default set up on the default theme is:

    <?php if (have_posts()) : ?>
    
    	<?php while (have_posts()) : the_post(); ?>
    
    		<div <?php post_class() ?> id="post-<?php the_ID(); ?>">
    			<h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2>
    			<small><?php the_time('F jS, Y') ?> <!-- by <?php the_author() ?> --></small>
    
    			<div class="entry">
    				<?php the_content('Read the rest of this entry &raquo;'); ?>
    			</div>
    
    			<p class="postmetadata"><?php the_tags('Tags: ', ', ', '<br />'); ?> Posted in <?php the_category(', ') ?> | <?php edit_post_link('Edit', '', ' | '); ?>  <?php comments_popup_link('No Comments »', '1 Comment »', '% Comments »'); ?></p>
    		</div>
    
    	<?php endwhile; ?>
    
    	<div class="navigation">
    		<div class="alignleft"><?php next_posts_link('&laquo; Older Entries') ?></div>
    		<div class="alignright"><?php previous_posts_link('Newer Entries &raquo;') ?></div>
    	</div>
    
    <?php else : ?>
    
    	<h2 class="center">Not Found</h2>
    	<p class="center">Sorry, but you are looking for something that isn't here.</p>
    	<?php get_search_form(); ?>
    
    <?php endif; ?>
    
    </div>

    Try that, I’ll tell you if it works on mine.

    @harrismc
    the link you found is in my opinion the best article on the topic; the codex is unfortunately rahter short on the subject of pagination with custom queries.

    i think your added trouble is how to define what you are trying to paginate, i.e. what the display of page2 should be.

    if you could clarify, what you want to show on page2, page3 etc, then it might be easier to help you past the link you’ve already found.

    if you are using the second loop as the base for the paginatioin, you also might need to add a ‘wp_reset_query();’ before the second loop.

    try to change this:

    <?php if (have_posts()) : ?>
    <?php rewind_posts(); ?>
    <?php 
    
    query_posts('posts_per_page=11');
    
    while (have_posts()) : the_post(); update_post_caches($posts);

    into this:

    <?php if (have_posts()) : ?>
    <?php rewind_posts(); ?>
    <?php
    wp_reset_query();
    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    query_posts('posts_per_page=11&paged='.$paged);
    
    while (have_posts()) : the_post(); update_post_caches($posts);

    this will obviously give you 11 post on the page2, etc.

    to get rid of the three posts from the first query you may need to use a conditional statement for it; something like
    <?php if(!is_paged()) { */first loop here*/ } ?>.

    http://codex.wordpress.org/Conditional_Tags&usg=ALkJrhihZeAd-cOg_CRVKm5kFg6YR_agEA#A_Paged_Page

    Thread Starter harrismc

    (@harrismc)

    Thanks

    <?php if (have_posts()) : ?>
    <?php rewind_posts(); ?>
    <?php
    wp_reset_query();
    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    query_posts('posts_per_page=11&paged='.$paged);
    
    while (have_posts()) : the_post(); update_post_caches($posts);

    This worked for me I got just what i was searching for.
    Thanks again

    Hi,

    Check with this page navigation plugin:

    http://wordpress.org/extend/plugins/wordpress-navigation-list-plugin-navt/

    Thanks,

    Shane G.

    Thread Starter harrismc

    (@harrismc)

    Navigation works fine, so here’s what I wanted to make it..
    At first page, first loop displays 3 latest post, and other 8 are displayed in short way, I have manage to do that, but my client wants that when he press next in page navigation , that those 3 latest don’t be displayed, only those short one’s. And what i got now is almost done , except I dont know how to remove those 3 “sticky” posts in next page…
    Any ideas ?

    Thread Starter harrismc

    (@harrismc)

    can I use is_home() or is_front_page() ?

    Thread Starter harrismc

    (@harrismc)

    Thread Starter harrismc

    (@harrismc)

    did you try what i suggested in my earlier reply:

    to get rid of the three posts from the first query you may need to use a conditional statement for it; something like

    <?php if(!is_paged()) { */first loop here*/ } ?> .

    http://codex.wordpress.org/Conditional_Tags&usg=ALkJrhihZeAd-cOg_CRVKm5kFg6YR_agEA#A_Paged_Page

    Thread Starter harrismc

    (@harrismc)

    Yes i tried it works but over the header of those mini posts im getting this error
    [function.in-array]: Wrong datatype for second argument in /home/droren/drorengel/blog/wp-content/themes/hp-blog/index.php on line 41

    Thread Starter harrismc

    (@harrismc)

    if ( !in_array( $post->ID, $do_not_duplicate ) ):
    This line i guess

Viewing 15 replies - 1 through 15 (of 21 total)
  • The topic ‘previous_posts_link next_posts_link problem’ is closed to new replies.