I am trying to figure out the right code to have my site call only a single post from one specific category, and list the only the titles of the next three posts underneath that will link to the full posts when clicked on.
I'm very new to PHP and i've been trying to look for solutions on the internet, but everything I find is in bits of pieces and has one aspect of what i'm looking to do but not others, and since I have a very limited understanding of PHP, combining the functionalities of everything I've found has proven very difficult and I've been unable to produce any results.
This is the code i'm currently using to grab only a specific category
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<!-- If the post is in the category we want to exclude, we simply pass to the next post. -->
<?php if (in_category('healthandwellness')) continue; ?>
<div class="post">
<h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
<small><?php the_time('F jS, Y'); ?></small>
<div class="entry">
<?php the_excerpt(200,"more"); ?>
</div>
<p class="postmetadata">Posted in <?php the_category(', '); ?></p>
</div> <!-- closes the first div box -->
<?php endwhile; else: ?>
<p>Sorry, no posts matched your criteria.</p>
<?php endif; ?>
I need a solution for getting only one specific category without having to list the 20 different categories that I don't want to show up like this current method would currently require me to do, and as mentioned before I only want it to display the single most recent post with only the titles of the follow three underneath.
Can anyone give me a solution? Your help is greatly apprecciated.