Jump to content

How to tweak my Jquery Masonry to make it look more grid-like using PHP?


koon0789

Recommended Posts

After days of agony, I finally figured out a way to display my blog posts masonry style.

However, I now want to find out if I can make it look exactly (or close to) the static design that I had before which is this : 

http://pier36nyc.com/events/

 

How my dynamic masonry looks like right now on my localhost: 

http://postimg.org/image/uy5jb4zax/

 

This is the code for the masonry:

<script>
  jQuery(document).ready(function($){
  var $container = $('#container').masonry();
      $container.imagesLoaded( function() {
  $container.masonry({ isFitWidth: true });;
        });
console.log ('JQuery Works');
});
</script>
 
===========
 
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<div class="box">
 
<div class="holder"> <!-- this is JQuery class -->
<?php if ( has_post_thumbnail() ): ?>
<?php echo the_post_thumbnail(); ?>
<?php else: ?> 
<?php echo the_content(); ?> 
<?php endif; ?>
 
<div class="info"> <!-- this is JQuery class -->
<p class="title"><?php the_title(); ?></p>
<p class="caption">
<?php if ( has_excerpt() ) : ?>
<?php the_excerpt(); ?>
<?php endif; ?></p>
<a href="<?php the_permalink() ?>"><input class="button1" type="button" value="VIEW EVENT" /></a>
</div>
</div>
</div>
<?php endwhile; endif; ?>
 
 
===================

 

The way my dynamic masonry look like that (I think) is because on the Php Code, it wraps every post in an individual class, hence giving it the same width. I feel like I need to tweak the logic, such as dividing posts into two categories : 'rectangle' and 'square', so that when the code generates the masonry, it will output the blocks in different shapes depending on the random generator.

 

 

 

Can you guys help me out with this one?
My knowledge in JQuery and PHP is very basic. I'm good at HTML and CSS but still learning JQ/PHP. 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.