Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I tried incrementally adding in my widget area to the masonry layout (PHP below) it appears but I cannot get it included into the masonry like the other blocks.

        $counts = 0 ;
        $addin = get_sidebar('masonry'); 

        foreach ($posts as $post) : setup_postdata($post); $counts++; ?>
                <div class="box">
                <?php  if($count == 9) {echo $addin;} else {?>
                <a href="<?php the_permalink() ?>">
                <h2><?php the_title(); echo $counts; // just to see ?></h2>
                <?php if (has_post_thumbnail()) {
                    the_post_thumbnail('thumbnail');
                }?>
                <?php the_content();?></a>
                </div><?php } endforeach; ?>

I also tried this jQuery but it broke my masonry:

jQuery(document).ready(function($){
    $('.arrange').masonry({
       itemSelector: '.box',
       isFitWidth: true,
    });
 $('#addinWidget').click(function(){
        var $container = $('#mas-widget');
        var addinWidget = $('<div class="element"><?php get_sidebar('masonry');?></div>');
        addinWidget.insertAfter($container.find('.element').eq(3));
        $container.masonry('reload');
    });

Could someone lead me in the right direction to place my widgets correctly inside the masonry layout AT/NEXT TO or IN FRONT OF a specified block number?

share|improve this question
    
Anybody have any advice at all? –  BenRacicot Jan 31 '13 at 3:26
add comment

1 Answer 1

up vote 1 down vote accepted

Figured it out! Here's the get_posts method to add a widget (or any content into a masonry layout at the "$counts" number you define)

<div class="arrange">
        <?php 
        $args = array(
            'posts_per_page'  => 10000,
            'offset'          => 5,
            'orderby'         => 'post_date',
            'order'           => 'DESC',
            'exclude'         => 'none',
            // 'post_type'       => array('post', 'page', 'video_type', 'review_type' ),
            'post_status'     => 'publish',
            'suppress_filters' => true 
            ); 

        $posts = get_posts($args);
        $counts = 0 ;
        foreach ($posts as $post) : setup_postdata($post); $counts++; 
            get_sidebar('corner-box');?>
                <div class="box"> 
                    <a href="<?php the_permalink() ?>">
                        <h2><?php the_title(); echo $counts; // to see your box number ?></h2>
                        <?php if (has_post_thumbnail()) {the_post_thumbnail('masonry');} 
                        the_content();?>
                    </a>
                </div><?php if($counts == 9) { get_sidebar('masonry');}
                endforeach; ?>

    </div> <!-- end masonry -->
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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