• Resolved now

    (@now)


    Hello,
    I have a question about the pagination.
    When I try to exclude the latest post on the home page of my blog, everything looks good. I mean I have the latest post displayed in a special way, with a bigger thumbnail
    and below the posts are diplayed. Working with the “offset” allowed me to exclude the latest post so that visitors would not see 2 times the same thumbnail.

    I thought everything was working but when i try to navigate to the next page using the paginated method at the bottom of my page, the same arrticles are shown again and again and again.

    Here is the code on my page. could anyone help me with this issue?
    Thanks in advance!

    <?php get_header(); ?>
    
    <div id="container">
    
    	<div id="hometop">
    
            <?php if(of_get_option('display_banner') == '1') { ?>
            <div id="textbanner">
    			<?php $recent = new WP_Query('page_id='.of_get_option('banner_text')); while($recent->have_posts()) : $recent->the_post();?>
                <h1><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></h1>
                <?php endwhile; ?>
            </div>
            <?php } else { ?>
            <?php } ?>
    
            <?php if(of_get_option('display_feature') == '1') { ?>
            <div id="homefeature">
    
    	        <div id="homearticle">
    				<?php $wp_query = new WP_Query(array('cat'=>of_get_option('home_feature'),'posts_per_page'=>1)); ?>
                    <?php if($wp_query->have_posts()) : while($wp_query->have_posts()) : $wp_query->the_post(); ?>
                    <?php $meta_box = get_post_custom($post->ID); $video = $meta_box['custom_meta_video'][0]; ?>
                    <?php global $more; $more = 0; ?>
    
                        <?php if ( $video ) : ?>
                            <div class="feature_video"><?php echo $video; ?></div>
                        <?php else: ?>
                            <a class="feature_img" href="<?php the_permalink() ?>" rel="bookmark"><?php the_post_thumbnail( 'home-feature' ); ?></a>
                        <?php endif; ?>
                        <div class="feature_info">
                            <h2><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></h2>
                            <?php the_excerpt(); ?>
                        </div>
    
                    <?php endwhile; ?>
                    <?php else : ?>
                    <?php endif; ?>
    	        </div>
    
    	        <div id="homewidgets">
    	            <?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar('Homepage Top Right') ) : ?>
    					<div class="widget">
    						<h4><?php _e("Widget Area", 'organicthemes'); ?></h4>
    						<p><?php _e("This section is widgetized. To add widgets here, go to the", 'organicthemes'); ?> <a href="<?php echo admin_url(); ?>widgets.php"><?php _e("Widgets", 'organicthemes'); ?></a> <?php _e("panel in your WordPress admin, and add the widgets you would like to the", 'organicthemes'); ?> <strong><?php _e("Homepage Top Right", 'organicthemes'); ?></strong>.</p>
    						<p><small><?php _e("*This message will be overwritten after widgets have been added.", 'organicthemes'); ?></small></p>
    					</div>
    	            <?php endif; ?>
    	        </div>
    
            </div>
            <?php } else { ?>
            <?php } ?>
    
        </div>
    
        <div id="homepage">
    
        	<?php include(TEMPLATEPATH."/sidebar_left_home.php");?>
    
            <div class="homepagemid">
    
    			<h3><?php echo cat_id_to_name(of_get_option('category_home')); ?></h3>
    
    			<?php $wp_query = new WP_Query(array('cat'=>of_get_option('category_home'),'posts_per_page'=>of_get_option('postnumber_home'),'paged'=>$paged)); ?>
    			<?php if($wp_query->have_posts()) : while($wp_query->have_posts()) : $wp_query->the_post(array()); ?>
                <?php $meta_box = get_post_custom($post->ID); $video = $meta_box['custom_meta_video'][0]; ?>
                <?php global $more; $more = 0; ?>
    
                	<div class="homepagecontent">
    
                        <?php if ( $video ) : ?>
    						<?php echo $video; ?>
                        <?php else: ?>
                            <a href="<?php the_permalink() ?>" rel="bookmark"><?php the_post_thumbnail( 'home-thumbnail' ); ?></a>
                        <?php endif; ?>
    
                        <div class="homeinfo">
    	                    <h2><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></h2>
    	                	<?php the_excerpt(); ?>
    
    	                	<?php if(of_get_option('display_socialhome') == '1') { ?>
    	                	<div class="social_links">
    	                	    <div class="tweet_btn">
    	                	        <a href="http://twitter.com/share" class="twitter-share-button"
    	                	        data-url="<?php the_permalink(); ?>"
    	                	        data-via="<?php echo of_get_option('social_twitter_url'); ?>"
    	                	        data-text="<?php the_title(); ?>"
    	                	        data-related=""
    	                	        data-count="horizontal"><?php _e("Tweet", 'organicthemes'); ?></a>
    	                	    </div>
    	                	    <div class="like_btn">
    	                	        <fb:like href="<?php echo urlencode(get_permalink($post->ID)); ?>" layout="button_count" show_faces="false" width="100" font=""></fb:like>
    	                	    </div>
    	                	    <div class="plus_btn">
    	                	    	<g:plusone size="medium"></g:plusone>
    	                	    </div>
    	                	</div>
    	                	<?php } else { ?>
    	                	<?php } ?>
    
                    	</div>
    
                    </div>
    
                <?php endwhile; ?>
    
    			<div id="pagination">
    			    <?php if (function_exists("number_paginate")) { number_paginate(); } ?>
    			</div>
    
                <?php else : ?>
    			<?php endif; ?>
    
            </div>
    
            <?php include(TEMPLATEPATH."/sidebar_home.php");?>
    
    	</div>
    
    </div>
    
    <?php get_footer(); ?>

Viewing 4 replies - 1 through 4 (of 4 total)
  • Here is an article with sample code to show a short first page. You will need to adapt the technique to your code.
    http://wordpress.mcdspot.com/2010/04/01/short-first-page/

    Thread Starter now

    (@now)

    Thanks for the hint.
    Unfortunately, I don’t understand how to change the code to exclude the latest post of showing un in the blog feed on the home page.

    If anyone can “show me” the solution, i would be grateful.

    Thanks anyway vtxyzzy!

    OK, I think it is simpler than I first thought.

    Add a ‘$do_not_duplicate’ variable into your ‘homearticle’ code like this:

    <div id="homearticle">
       <?php $wp_query = new WP_Query(array('cat'=>of_get_option('home_feature'),'posts_per_page'=>1)); ?>
       <?php if($wp_query->have_posts()) : while($wp_query->have_posts()) : $wp_query->the_post(); ?>
       <?php $do_not_duplicate = $post->ID; ?>

    Then add the ‘post__not_in’ argument to your main query like this:

    <?php $wp_query = new WP_Query(array('cat'=>of_get_option('category_home'),'posts_per_page'=>of_get_option('postnumber_home'),'paged'=>$paged,'post__not_in' => array($do_not_duplicate))); ?>
    Thread Starter now

    (@now)

    WOW.
    THANK YOU SO MUCH!
    works as a charm!
    best regards.
    solved thanks to vtxyzzy!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘pagination broken when excluding latest post on homepage’ is closed to new replies.