• Resolved jimmytubbs

    (@jimmytubbs)


    I want to show a certain category in this code */ the code is displayed in a page so thats why i’m not sure if it has to be differen’t */

    <?php
    if (is_page('21') ) {
    $cat = array(12);
    } elseif ( is_page('16') ) {
    $cat = array(32);
    } elseif ( is_page('28') ) {
    $cat = array(17);
    } else {
    $cat = '';
    }
    
    $showposts = -1; // -1 shows all posts
    $do_not_show_stickies = 1; // 0 to show stickies
    $args=array(
       'category__in' => $cat,
       'showposts' => $showposts,
       'caller_get_posts' => $do_not_show_stickies,
       );
    $my_query = new WP_Query($args); 
    
    ?>
    <?php if( $my_query->have_posts() ) : ?>
    
    		<?php while ($my_query->have_posts()) : $my_query->the_post(); ?>
    			<?php
    			//necessary to show the tags
    			global $wp_query;
    			$wp_query->in_the_loop = true;
    			?>
    			<div <?php post_class() ?> id="post-<?php the_ID(); ?>">
    <div id=news><h2><a>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></h2></a></div>
    <?php the_excerpt(); ?>
     <h4><span id=news>Written by <?php the_author();?> at <?php the_time();?> <a>" rel="bookmark">Read More.... &nbsp; &nbsp <?php comments_number(); ?></a> </span></h4>
    <?php endwhile; else: ?>
    <div id=footerbg">
    			<div class="alignleft"><?php next_posts_link('« Older Entries') ?></div>
    			<div class="alignright"><?php previous_posts_link('Newer Entries »') ?></div>
    		</div>
    
    <p>Sorry, no posts matched your criteria.</p>
    <?php endif; ?>

Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Showing posts for a certain catagory’ is closed to new replies.