• My last blog post shows twice (as post number one and two) and I can’t figure out why. Here’s my index.php

    <?php get_header(); ?>
    	<div id="content">
    
    <?php if ( is_home() ) {
    query_posts($query_string . '&cat=-2');
    }
    ?>
    
    	<?php if (have_posts()) : ?>
    
    <?php while (have_posts()) : the_post(); ?>
    
    			<div class="post" id="post-<?php the_ID(); ?>">
    				<h1><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a></h1>
    								<p class="postmetadata">I
    	  <?php the_category(', ') ?> | <?php edit_post_link('Edit', '', ' | '); ?>  <?php the_time('l, F jS, Y') ?> | <?php comments_popup_link('0 Kommentarer »', '1 Kommentar »', '% Kommentarer »'); ?> | <?php if(function_exists('wp_print')) { print_link(); } ?> | <a href="<?php trackback_url(true); ?> " rel="trackback">Trackback</a></p> 
    
    							<span style="display:none;"><?php todays_overall_count($post->ID, '', '', '', '0'); ?></p></span>
    				                <div class="entrytext">
    					<?php the_content('Fortsätt läsa artikeln &raquo;'); ?>
    				</div>
    
    		</div>
    
    		<?php endwhile; ?>
    
    		<div class="navigation">
    			<div class="alignleft"><?php next_posts_link('Äldre inslag') ?></div>
    			<div class="alignright"><?php previous_posts_link('Nyare inslag') ?></div>
    		</div>
    
    	<?php else : ?>
    
    		<h2 class="center">Vi hittar inte det du söker.</h2>
    		<p class="center">Vi hittar ingen matchning till den söktermen. Prova något annat.</p>
    		<?php include (TEMPLATEPATH . "/searchform.php"); ?>
    
    	<?php endif; ?>
    
    	</div>
    <?php get_sidebar(); ?>
    <?php get_footer(); ?>

    Has anyone experienced a similar problem and found a solution?

Viewing 10 replies - 1 through 10 (of 10 total)
  • Thread Starter Blaque

    (@blaque)

    I think it has something to do with that initial exclusion of category 2 posts from the home page. But I have no idea what the problem is!?

    I know this is old post but same thing is happening on my blog now and I can’t figure out what am I doing wrong. Everything was working fine, I just upgraded my WP 2.6.3 blog to the latest version 3.0.4 and now the latest post link appears twice on the index page. Can anyone help me out here please? Any help would be highly appreciated.

    Regards.

    Moderator keesiemeijer

    (@keesiemeijer)

    Please provide a link to your website and a link to your theme if possible.

    Hello keesiemeijer,

    My blog link: http://www.toptenservices.net/
    If you look on the left, under RECENT REVIEWS, you will see the latest review link twice.

    Here is the code that’s called to show reviews:
    http://wordpress.pastebin.com/zVCuUxHg

    Your help is appreciated,

    Regards.

    Moderator keesiemeijer

    (@keesiemeijer)

    Are you using a plugin to show the reviews?
    $reviews = tts_recent_reviews(4,'');

    Try it with this. change this:

    //show last 4 reviews
    			//$reviews = get_posts('category_name=reviews&orderby=date&order=desc&numberposts=3');
    			$reviews = tts_recent_reviews(4,'');

    to this:

    //show last 4 reviews
    			$reviews = get_posts('category_name=reviews&orderby=date&order=desc&numberposts=3');
    			// $reviews = tts_recent_reviews(4,'');

    Just a wild guess.

    Thanks for the help keesiemeijer,

    Tried that but as you can see, nothing shows up now.
    that tts_recent_reviews thing is in the function.php file.
    Actually, this blog was customized by a kick-ass programmer, I haven’t yet seen anyone better than this guy but he is way too busy to customize my blog now. Secondly, I wish to try fixing this on my own or with the community’s help.
    Appreciate that you are trying to help me. So, what can we try next? Do you want me to post the function.php file content? Please let me know.

    Regards.

    Here is the code from functions.php file that calls for latest reviews:

    //get last 3 reviews
    function tts_recent_reviews($limit,$user)
    {
    	global $wpdb;
    	if($user != "") {
    		$user_filter = " AND post_author = '$user' ";
    	}
    	$sql = "SELECT ID
    			FROM wp_posts
    			LEFT JOIN wp_postmeta on wp_postmeta.post_id = wp_posts.ID
    			WHERE wp_posts.post_type = 'post'
    			AND wp_postmeta.meta_key = 'is_review'
    			AND wp_posts.post_status = 'publish'
    			$user_filter
    			ORDER BY post_date DESC LIMIT $limit";
    	$results = $wpdb->get_results($sql);
    	if(empty($results)) {
    		return false;
    	} else {
    		return $results;
    	}
    }

    Moderator keesiemeijer

    (@keesiemeijer)

    try it with:

    //show last 4 reviews
    			$reviews = get_posts('meta_key=is_review&orderby=date&order=desc&numberposts=4');
    			// $reviews = tts_recent_reviews(4,'');

    Moderator keesiemeijer

    (@keesiemeijer)

    or try it in the sql:

    $sql = "SELECT DISTINCT ID
    FROM wp_posts
    			LEFT JOIN wp_postmeta on wp_postmeta.post_id = wp_posts.ID
    			WHERE wp_posts.post_type = 'post'
    			AND wp_postmeta.meta_key = 'is_review'
    			AND wp_posts.post_status = 'publish'
    			$user_filter
    			ORDER BY post_date DESC LIMIT $limit";

    and use:
    $reviews = tts_recent_reviews(4,'');

    Sorry for the late reply but WHOA!

    This worked like charm:

    //show last 4 reviews
    			$reviews = get_posts('meta_key=is_review&orderby=date&order=desc&numberposts=4');
    			// $reviews = tts_recent_reviews(4,'');

    Thank you so so much buddy, you are a champ 🙂
    The site is working flawless now. Appreciate your help a lot! Thanks a lot, two thumbs up for you 🙂

    Regards.

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘Latest post shows twice’ is closed to new replies.