• Resolved mtibbits

    (@mtibbits)


    So I had this site up and running and everything working.

    The client was entered a bunch of posts today and now everything has disappeared from the “homepage”, which should be showing posts from 3 different categories.

    If I go directly to any of my categories all posts show up.

    I tried re-doing my permalinks, but same thing.

    Anyone have any ideas? All my code still works on my local test machine for this site, so I’m thinking it must be a setting…

    This was supposed to go live tomorrow, so any help would be greatly appreciated!

    Thanks in advance,

    Matt

Viewing 14 replies - 1 through 14 (of 14 total)
  • Different category id’s from your test bed to their live site?

    Thread Starter mtibbits

    (@mtibbits)

    I’m using the “permalink” names for my categories. (ie. “events” instead of “4”) and they are the same…

    Thread Starter mtibbits

    (@mtibbits)

    I was using the “page links to” plugin for my news and job bank links, as they are posts and not pages… it seemed to happen after she entered the posts in the job-bank category.

    I disabled the plug-in and same thing. Re-enabled, and same thing.

    Thread Starter mtibbits

    (@mtibbits)

    Another thing… if I switch from my theme to the default, it shows my posts from most recent to oldest on the front page.

    I copied the loop from index.php in the default theme, and it still shows up as blank.

    Thread Starter mtibbits

    (@mtibbits)

    And if this helps any… if I delete the following from my code:

    if (!in_category('events')) continue; ?>

    I get the listing of full posts.

    Here is my full “loop” code:

    <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    
    	<?php
    	static $count = 0;
    	if ($count == "2") { break; }
    	else { 
    
    	if (!in_category('events')) continue; ?>
    
    	<?php if ($count < 1) {
    		echo '<h1>';
    		the_category(', ');
    		echo '</h1>';
    	}?>
    
    	<div class="post">
    		<h2><a href="<?php the_permalink(); ?>" rel="bookmark" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a>
    		</h2>
    
    		<div class="entry">
    			<?php the_content('Read more...'); ?>
    		</div>
    	</div>
    
    	<?php $count++; } ?>
    
    	<?php endwhile; ?>

    So the goal is to show, on the main page, the lastest post, one from each of 3 categories?
    .

    Thread Starter mtibbits

    (@mtibbits)

    Basically, 2 from events and 1 each from featured-employer and featured-partner.

    Then I have links to news and the job-bank categories.

    And I just noticed if I change my code so job-bank shows on the main page it works, but none of the other categories do.

    Like these:

    <?php
    $cat=get_cat_ID('events');
    $posts = get_posts("cat=$cat&showposts=2");
    if ($posts) {
    foreach($posts as $post) {
    setup_postdata($post);
    ?>
    	<div class="post">
    		<h2><a href="<?php the_permalink(); ?>" rel="bookmark" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a>
    		</h2>
    
    		<div class="entry">
    			<?php the_content('Read more...'); ?>
    		</div>
    	</div>
    <?php
    }
    }
    ?>
    
    <?php
    $cat=get_cat_ID('Featured Employer');
    $posts = get_posts("cat=$cat&showposts=1");
    if ($posts) {
    foreach($posts as $post) {
    
    setup_postdata($post);
    ?>
    	<div class="post">
    		<h2><a href="<?php the_permalink(); ?>" rel="bookmark" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a>
    		</h2>
    
    		<div class="entry">
    			<?php the_content('Read more...'); ?>
    		</div>
    	</div>
    <?php
    }
    }
    ?>
    
    <?php
    $cat=get_cat_ID('Featured Partner');
    $posts = get_posts("cat=$cat&showposts=1");
    if ($posts) {
    foreach($posts as $post) {
    
    setup_postdata($post);
    ?>
    	<div class="post">
    		<h2><a href="<?php the_permalink(); ?>" rel="bookmark" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a>
    		</h2>
    
    		<div class="entry">
    			<?php the_content('Read more...'); ?>
    		</div>
    	</div>
    <?php
    }
    }
    ?>

    Thread Starter mtibbits

    (@mtibbits)

    that sort of works…but it’s showing the job-bank posts instead of events…

    And my code did work until the job-bank posts were added…

    I left it with your code so you can see what it does…

    Thread Starter mtibbits

    (@mtibbits)

    I just changed “events”, which is the slug to the category name, “Upcoming Events” and it shows them….

    If this code will do it that’s great, but I’m wondering why mine worked before, and now doesn’t once the job-bank posts are added??

    It looks like your $count logic wasn’t quite right.

    Thread Starter mtibbits

    (@mtibbits)

    So using the code you gave me, I’ve added h1 tags to place the category title. I’d like to link the title to that category archives like so:

    <?php
    $cat=get_cat_ID('Upcoming Events');
    $posts = get_posts("cat=$cat&showposts=2");?>
    <h1><?php the_category(', ') ?></h1>
    <?php
    if ($posts) { ... and so on

    In this instance it returns “Job Bank” as the title and links to that category…

    How would I fix it?

    the_category has to be placed after the setup_postdata meaning it has to be in The Loop.

    Template_Tags/the_category

    Thread Starter mtibbits

    (@mtibbits)

    Got it. Thanks a million for your help. It is greatly appreciated!

Viewing 14 replies - 1 through 14 (of 14 total)

The topic ‘HELP!! Posts disappeared from front page’ is closed to new replies.