Forum Replies Created

Viewing 3 replies - 1 through 3 (of 3 total)
  • This might be a bit rough around the edges…
    Also I don’t even know if this is correct PHP ?? Am a bit rusty…
    It does work how I want it as far as i can tell…

    Maybe someone got an idea how to change it so it displays more than one post ??

    <?php
    $feature_id = '3'; //enter the featured cat_id
    
    $feature = new WP_Query('cat='.$feature_id.'&showposts=1');
    while($feature->have_posts()) : $feature->the_post();
    $featured_post_id = $post->ID;
    echo 'featured_post_id: '.$featured_post_id;
    $thecats = get_the_category();
    foreach($thecats as $thecat)
      $feature_post_cats[] = $thecat->term_id;
    endwhile;
    echo '<br />feature_post_cats: '; print_r ($feature_post_cats); ?><br /><br />
    
    <?php $categories = get_categories('exclude='.$feature_id);
    foreach ($categories as $category) {
    echo 'category: '; print_r ($category); echo '<br /><br />';
    $cats = new WP_Query('cat='.$category->cat_ID.'&showposts=2');
    while($cats->have_posts()) : $cats->the_post();
    $check = $post->ID;
    if ($check == $featured_post_id) :
    echo 'post: del->'.$post->ID.' - skip this one<br /><br />'; continue;
    endif;
    echo 'post: keep->'.$post->ID.'<br /><br />'; break;
    endwhile;
    } ?>

    edit: gawd, i’ve been editing the heck out of this entry ??

    Mores, thank you for the code. I thought it was the problem’s solution.. But there’s something wrong with it.. Or maybe it’s me being silly. Dont know..

    I have “Cat1” and “Feature”.. Now I post something i want to be featured in both categories.. and the script works fine. But when I post a new article in “Cat1” but not “Featured”, the newest article will not be shown, because the script offsets the Cat1 by 1, because the featured post is in Cat1, as well.

    Effectively duplicating the featured entry.

    Maybe check if the newest entry in the $mycatsid categories is the featured post, and if so, THEN offset by 1?..

    Can someone elaborate? Or help me? ??

    Thread Starter tilmeister

    (@tilmeister)

    Solution here
    *whistles* i’ll be gone then ??

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