Need Help with archive display from one category

Discussion in 'PHP' started by surfnearnzone, Feb 22, 2012.

  1. #1
    Can anyone please help me with showing posts from only one category?? Currently, all the posts are displayed. Below is the code that I am using to display all categories posts:

    <?php wp_get_archives('type=postbypost&limit=30'); ?>
    Code (markup):
    I tried this but didn't work:

    <?php query_posts('cat=701&showposts=1'); ?>
    Code (markup):
    and

    <?php wp_get_archives('cat=701'); ?>
    Code (markup):
    Can anybody tell me how to do it
     
    surfnearnzone, Feb 22, 2012 IP
  2. surfnearnzone

    surfnearnzone Well-Known Member

    Messages:
    1,492
    Likes Received:
    62
    Best Answers:
    0
    Trophy Points:
    165
    #2
    Can somebody help me with this code to show posts only from given category??
    
    <!-- Category Archive Start -->
    
    <?php
    
    $catQuery = $wpdb->get_results("SELECT * FROM $wpdb->terms AS wterms INNER JOIN $wpdb->term_taxonomy AS wtaxonomy ON ( wterms.term_id = wtaxonomy.term_id ) WHERE wtaxonomy.taxonomy = 'category' AND wtaxonomy.parent = 0 AND wtaxonomy.count > 0");
    
    $catCounter = 0;
    
    foreach ($catQuery as $category) {
     
    $catCounter++;
    
    $catStyle = '';
    
    if (is_int($catCounter / 2)) $catStyle = ' class="catAlt"';
    
    $catLink = get_category_link($category->term_id);
    
    echo '<li'.$catStyle.'><h3><a href="'.$catLink.'" title="'.$category->name.'">'.$category->name.'</a></h3>';
    
    echo '<ul>';
    
    query_posts('cat='.$category->term_id.'&showposts=5');?>
    
    <?php while (have_posts()) : the_post(); ?>
    
    <li><a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title(); ?>"><?php the_title(); ?></a></li>
    
    <?php endwhile; ?>
    
    <li><a href="<?php echo $catLink; ?>" title="<?php echo $category->name; ?>">More <strong><?php echo $category->name; ?></strong></a></li>
    
    </ul>
    
    </li>
    
    <?php }  ?>
    
    <!-- Category Archive End --> 
    Code (markup):
     
    surfnearnzone, Feb 22, 2012 IP
  3. surfnearnzone

    surfnearnzone Well-Known Member

    Messages:
    1,492
    Likes Received:
    62
    Best Answers:
    0
    Trophy Points:
    165
    #3
    Solution found, thanks for looking...
     
    surfnearnzone, Feb 22, 2012 IP