Alright I have read and I want to use that code for my home page showing only one category of posts.
This is the code on the page you linked:
Show One Category by Name
Display posts from only one category by name:
query_posts('category_name=Staff Home');
My category name is: One Man Band
Here is my index.php:
<?php get_header();?>
<div style="clear:both;"></div>
<div id="contentwrap">
<div id="content">
<div id="banner">
</div>
<div id="aligner">
<!-- <div id="fun"></div> -->
<?php global $wp_query;
query_posts(
array_merge(
$wp_query->query,
array('orderby' => 'rand')
)
);?>
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<div onclick="location.href='<?php the_permalink() ?>';" style="cursor:pointer;background:#<?php echo rand(0, 9); ?><?php echo rand(0, 9); ?><?php echo rand(0, 9); ?><?php echo rand(0, 9); ?><?php echo rand(0, 9); ?><?php echo rand(0, 9); ?>;" class="post bg thickbox" id="thickbox post-<?php the_ID(); ?>">
<div class="bg">
<div class="posttitle">
<a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a>
</div>
<div>
<small>
Album: <?php the_category(', '); ?> |
</small>
</div>
<div align="center" class="entrywhole">
<div align="left" class="entry">
<?php post_thumb(); ?><?php the_excerpt('Read more »'); ?>
</div>
</div>
</div>
</div>
<?php endwhile; ?>
<?php endif; ?>
<div style="clear:both;"></div>
</div>
<div align="center" id="navlink">
<?php posts_nav_link(); ?>
</div>
</div>
<?php get_sidebar();?>
</div>
<?php get_footer();?>
I have tried to put the code in some places but I always result to a syntax error…
Can you help me find the right place to put my new code please? Thanks in advance 🙂
I got it!!! I added this code over the orderby one!
<?php global $wp_query;
query_posts(
array_merge(
$wp_query->query,
array('category__in' => array(20))
)
);?>
Had to find out that my array was number 20 for the right category lol. I tried 1,2,3,4 etc.