0

I am trying to make Wordpress theme with bootstrap 3.x. This is my first theme and I am experimenting with Wordpress and bootstrap various features. I would like to use Wordpress sticky post feature to create three side by side columns, but I do not know how to do that. If I use

?php if (have_posts()) : while (have_posts()) : the_post();
$mythemename_post_format = get_post_format();
get_template_part('templates/post', $mythemename_post_format);
<?php endif; ?>

all the posts including those which are checked as sticky posts will appear under the three columns I am taking about.

My plan is to add the codes in the following way:

<div class="row">
        <div class="container">
            <div class="col-sm-4">
                <!—code for the first column—>
            </div>
            <div class="col-sm-4">
                <!—code for the second column—>
            </div>
            <div class="col-sm-4">
                <!—code for the third column—>
            </div>
        </div>
    </div>

Any ideas would be appreciated. Regards

1 Answer 1

0
<?php if (have_posts()){ ?>
    <?php while(have_posts()){ 
        the_post();
        if(is_sticky()){ ?>
            <div class="col-sm-4">
                <?php //put what you want, Hey you inside the loop now ?>
            </div>
        <?php }else{
                  $mythemename_post_format = get_post_format();
                  get_template_part('templates/post', $mythemename_post_format);
              }
    } ?>
2
  • Thanks for responding. Maybe I was not clear above, but I just need to know how I can call the first three sticky posts for the three respective divs with col-sm-4 classes.
    – Mike
    Commented Oct 20, 2015 at 20:32
  • OK, I edit My code to check if the post sticky or not, You can just use is_sticky() inside the loop Commented Oct 20, 2015 at 20:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.