WordPress.org

Forums

Excluding all categories but one, in 'Recent News' in side panel. What code? (5 posts)

  1. Jebaloo
    Member
    Posted 7 years ago #

    Hi,

    Please see the right side panel on my site: http://lacrossescotland.com/

    There is a Recent News section, and the code for this is:

    <h2>Recent News:</h2>

      <?php if (in_category('General') && is_home() ) stop; ?>
      <?php get_archives('postbypost', 3); ?>

    I would like to know how to exclude all categories from the Recent News, except for 'General'.

    I'm sure this is simple, but I've searched everywhere and can't find it.

    Any help would be greatly appreciated.
    Thanks.

  2. Jebaloo
    Member
    Posted 7 years ago #

    I've found out how to exclude just one category (code below), but still can't work out how to only show one category of news entries:

    <li id="Recent">
    <h2>Recently Written</h2>

    Any help on this would be awesome.

  3. Jebaloo
    Member
    Posted 7 years ago #

    <li id="Recent">
    	<h2>Recently Written</h2>
    <ul>
    <?php $temp_query = $wp_query; query_posts('showposts=10&cat=-88'); ?>
    <?php while (have_posts()) { the_post(); ?>
    <li><a href="<?php the_permalink(); ?>" rel="bookmark" title="Permanent Link to &ldquo;<?php the_title(); ?>&rdquo;"><?php the_title(); ?></a></li>
    <?php } $wp_query = $temp_query; ?>
    </ul>
    </li>

    Sorry for the previous posts's scrambled code.

  4. Jebaloo
    Member
    Posted 7 years ago #

  5. Jebaloo
    Member
    Posted 7 years ago #

    Resolved.

Topic Closed

This topic has been closed to new replies.

About this Topic