• I am trying to run the loop showing 4 posts, which goes into a bootstrapped tablist, then show the next 4 posts in a tabbed list and so on.

    the logic is messing my brain – here is where I am at.

    ‘<?php
    $ingredients = new WP_Query(‘cat=6&showposts=-1’);
    $a = query_posts(‘category_name=my_category’);
    $result = count($a);
    $count = 1;

    $i = 1;
    while (have_posts() && $i < 5) : the_post(); ?>

    <?php if ($i == 1) echo ‘<ul class=”nav nav-tabs” role=”tablist”>’ ?>

    <li >” role=”tab” data-toggle=”tab” rel=”bookmark” title=”<?php the_title(); ?>”><?php echo get_the_post_thumbnail( $post_id, array( 100, 100) ) ?>
    <?php echo the_title(); ?>

    <?php $i++; endwhile; ?>

    <?php

    echo ‘<div class=”tab-content”>’;
    $ingredients = new WP_Query(‘cat=6&showposts=-1’);

    while($ingredients->have_posts()) : $ingredients->the_post();
    $count++
    ?>
    <div role=”tabpanel” class=”tab-pane fade in ” id=”<?php the_ID(); ?>”><?php the_content(); ?></div>

    <?php endwhile; ?>

    </div>’

    Little bit of a newbie here and just cannot figure out the count.
    Any help would be appreciated.

Viewing 1 replies (of 1 total)
  • @Diggety

    I’ve not used bootstrap in quite awhile, so please excuse my ignorance when it comes to tabulated functionality. Linked below is an example ( heavily notated ) which explains loops.

    The example, however, is NOT final code, you’ll see it’s missing the UL tags and the recipe content section.

    I’m not entirely sure what you’re trying to achieve. I’m assuming it’s a tabbed list of recipes. Whereas the recipes reside under category ID 6. But, instead of using category titles as tab titles, you’re using a post thumbnail from that category?

    If that’s the case, you’ll want to use the offset code linked on the tab panel instead of the navigation.

    Anyhow, here’s the link, hope you get something from it!
    https://gist.github.com/38453e6e0d5703485a4d

Viewing 1 replies (of 1 total)
  • The topic ‘how to display a specific number of posts and repeat’ is closed to new replies.