Forum Replies Created

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter ascoltalatuasete

    (@ascoltalatuasete)

    Thank you very much!
    I’ve correct a bit your code ($category is an object, $category->term_id is the category ID), and added default, that contains all parameters (i want to see categories with no posts so i’ve set to false hide_empty parameter).

    this is my running code ??

    $defaults=array('type'=>'post',
    'child_of'=> 23,
    'orderby'=>'name',
    'order'=>'ASC',
    'hide_empty'=> false,
    'include_last_update_time'=>false,
    'hierarchical'=>1,
    #'exclude'=> ,
    #'include'=> ,
    #'number'=> ,
    'pad_counts'=>false);
    
    foreach(get_categories($defaults) as $category) : ?>
        <div class="cat_box">
        <h4><? echo $category->name ?></h4>
        <?php $getposts =get_posts('numberposts=5&category='.$category->term_id);
    
        foreach($getposts as $post) : setup_postdata($post); ?>
    
          <? the_title() ?>
    
        <?php endforeach; ?>
      </div><!-- box -->
    <?php endforeach; ?>
    Thread Starter ascoltalatuasete

    (@ascoltalatuasete)

    Or is this just a typo?

    Ops! yes…

    And just keep repeating, putting the ID where it says cat=XX&showposts=1.

    uhm…
    i’ve 12-13 categories and they are dynamic: i prefer not to do manually each box in my template.
    i was thinking for a code liche this:
    `
    <?
    for each category witch parent is 23:?>
    <div class=”box”>
    <?php query_posts(‘cat=’.$category->id.’&showposts=5′); ?>
    <h2><? echp($category->title) ?></h2>
    <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    <h3><?php the_title(); ?></h3>
    <?php the_excerpt(); ?>
    <?php endwhile; else:?>
    <?php endif; ?>

    i can’t do the first for: for each category witch parent is 23:

    Thank you for the reply!

Viewing 2 replies - 1 through 2 (of 2 total)