php code help – category posts
-
Hi there.
I’m in the process of building a site requiring current job postings (which are managed through categories). But there’s a section I can’t figure out. The spot where I have Nothing available at this time, I would like for it to appear automatically if there are no posts in the category.what I have so far is this, but I don’t want to have to keep changing it manually to add in the nothing available at this time part. Hopefully I’m explaining this right.
This is part of a page template that i’ve created to list these.
<h3>Current Employment Opportunities</h3> <h4>Department 1<ul> <h5>Nothing available at this time</h5></ul> <ul> <?php$latest = get_posts('cat=-1,-2,-3,-7,-8,-10,-11&numberposts=10'); foreach( $latest as $post ):?> <li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a> | <?php the_time('j M'); ?></li> <?php endforeach ?> </ul></h4> <h4>Department 2<ul> <?php$latest = get_posts('cat=-1,-2,-3,-4,-5,-6,-8,-9,-10,-11&numberposts=10'); foreach( $latest as $post ):?> <li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a> | <?php the_time('j M'); ?></li> <?php endforeach ?> </ul></h4>
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘php code help – category posts’ is closed to new replies.