• Hi

    the site in question: http://www.thebeepseals.com

    I amended index.php per another post on here so as to show only posts from the news category on the home page. this was working fine until today. it seems like perhaps the posts have expired? if i click ‘older posts’ they appear but they no longer appear by default on the home page. i’m new to wordpress so not sure how to approach fixing this. basically i want the last 5 posts of the news page to appear on the home page by default and not expire.

    here is my index.php code as it is now:

    <?php
    get_header();
    ?>
    
    <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    <?php if ( (in_category('1')) || !is_home() ) { ?>
    <!-- Output the post here -->
    <?php the_date('','<h2>','</h2>'); ?>
    
    <div class="post" id="post-<?php the_ID(); ?>">
    	 <h3 class="storytitle"><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></h3>
    
    	<div class="storycontent">
    		<?php the_content(__('(more...)')); ?>
    	</div>
    
    	<div class="feedback">
    		<?php wp_link_pages(); ?>
    		<?php comments_popup_link(__('Comments (0)'), __('Comments (1)'), __('Comments (%)')); ?>
    	</div>
    
    </div>
    
    <?php comments_template(); // Get wp-comments.php template ?>
    
    <?php } ?>
    <?php endwhile; else: ?>
    <p><?php _e('Sorry, no posts matched your criteria.'); ?></p>
    <?php endif; ?>
    
    <?php posts_nav_link(' — ', __('&laquo; Newer Posts'), __('Older Posts &raquo;')); ?>
    
    <?php get_footer(); ?>
Viewing 10 replies - 1 through 10 (of 10 total)
  • there isnt anything wrong with that code, assuming news is category id #1 OR is_home is your index.php.

    http://www.thebeepseals.com/?cat=1 = (news is 1)

    Plugins used are?

    Thread Starter jarin

    (@jarin)

    no plugins..
    why have the news posts disappeared from the home page tho? thanks

    !is_home()
    This means “is NOT home”, so the code is doing what it is supposed to do: hide the posts on home page, because your code is saying show the posts only when we are NOT on the homepage.

    No
    that code says:

    If in cat 1 OR not at home. ONLY one of those needs to be true, or both.

    If you want to prove that out, go plug it on your own site. Trust me, it’s right.

    Thread Starter jarin

    (@jarin)

    ah ok..so i’ve taken out the “!” making the if clause into:

    <?php if ( (in_category('1')) || is_home() ) { ?>

    but now it’s showing latest posts from all categories..

    how would i get it to only show latest posts from news (ie cat 1)?

    thx

    if thats the case the trouble is with the in_category bits NOT the code itself. what you did was you made the second variable true..

    || = or

    Your code know says :

    if in category 1 OR at home: do something.

    and its not displaying ALL posts .. its left out the category 1 ones.

    That code will definitely not do it.
    Search: http://wordpress.org/support/topic/156069?replies=9
    lots of options there.

    change this:

    <?php if ( (in_category('1')) || !is_home() ) { ?>

    to this:

    <?php if (in_category('1') || !is_home() ) { ?>

    My php guru insists there isnt any functional diff. between those but I disagree. That will fix it.

    Where is Otto when you need him??

    Thread Starter jarin

    (@jarin)

    hey whooami..thanks for that..however i think im back at square one where the posts from the news category have disappeared from the home page. i suspect it’s because they are several days old? how can i keep them up there permanently (the most recent 5 posts at least)..?

    rudolf45: im checkin out that link thanks for that

    Thread Starter jarin

    (@jarin)

    ok guys i solved this. it now only shows cat 3 on the home page! thanks!

    here’s the code if anyone’s interested:

    <?php
    get_header();
    ?>
    
    <?php if (is_home() ) { ?>
    <?php query_posts('cat=1'); ?>
    <?php } ?>
    <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    
    <!-- Output the post here -->
    <?php the_date('','<h2>','</h2>'); ?>
    
    <div class="post" id="post-<?php the_ID(); ?>">
    	 <h3 class="storytitle"><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></h3>
    
    	<div class="storycontent">
    		<?php the_content(__('(more...)')); ?>
    	</div>
    
    	<div class="feedback">
    		<?php wp_link_pages(); ?>
    		<?php comments_popup_link(__('Comments (0)'), __('Comments (1)'), __('Comments (%)')); ?>
    	</div>
    
    </div>
    
    <?php comments_template(); // Get wp-comments.php template ?>
    
    <?php endwhile; else: ?>
    <p><?php _e('Sorry, no posts matched your criteria.'); ?></p>
    <?php endif; ?>
    
    <?php posts_nav_link(' — ', __('&laquo; Newer Posts'), __('Older Posts &raquo;')); ?>
    
    <?php get_footer(); ?>
Viewing 10 replies - 1 through 10 (of 10 total)

The topic ‘Posts disappeared’ is closed to new replies.