Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // An explanation on using:
- // http://wp.tutsplus.com/tutorials/theme-development/using-jquery-masonry-for-pinterest-like-posting/
- /************************** This goes in your functions.php **************************/
- //script enque
- function mason_script() {
- wp_enqueue_script( 'jquery-masonry' );
- }
- add_action( 'wp_enqueue_scripts', 'mason_script' );
- /****** Create a new php file and name it whatever you want, this will act as a page template. *********************/
- /************************** Put this inside of that new php file **************************/
- <?php
- /**
- * Template Name: Masonry Blog
- *
- * Blog Template
- *
- */
- ?>
- <?php include_once( 'header.php' ); ?>
- <!-- Start the Loop. -->
- <div id="container2">
- <?php
- $temp = $wp_query;
- $wp_query= null;
- $wp_query = new WP_Query();
- $wp_query->query('posts_per_page=100'.'&paged='.$paged);
- while ($wp_query->have_posts()) : $wp_query->the_post();
- ?>
- <div class="brick">
- <div class="brick_header">
- <a href="<?php the_permalink() ?>" rel="bookmark" title="Click to view: <?php the_title_attribute(); ?>">
- <?php the_title(); ?></a>
- </div>
- <div class="brick_featured_image">
- <?php if ( has_post_thumbnail() ) {
- $size=75;
- ?>
- <a href="<?php the_permalink() ?>" rel="bookmark" title="Click to view: <?php the_title_attribute(); ?>">
- <?php the_post_thumbnail( $size ); } ?>
- </a>
- </div>
- <?php the_excerpt(); ?>
- <a href="<?php the_permalink() ?>" title="<?php the_title(); ?>" class="read_more_link">Read More</a>
- </div>
- <?php endwhile;?>
- <?php $wp_query = null; $wp_query = $temp;?>
- <!-- stop The Loop. -->
- </div><!-- container -->
- <?php get_footer(); ?>
- /*********************** Put this in your styles.css file or whateve stylesheet you use **************************/
- /* masonry brick layout */
- #container2 {
- width: 100%; /* width of the entire container for the wall */
- margin-bottom: 10px;
- }
- .brick {
- width: 20%; /* width of each brick less the padding inbetween */
- padding: 0px 10px 15px 10px;
- background-color: #383838;
- margin-top: 5px;
- }
- .brick_header{
- border-bottom: solid 1px #1d1d1d;
- padding-bottom: 10px;
- padding-top: 10px;
- }
- .brick_header a{
- color: #ffff00;
- }
- .brick_header a:hover{
- color: white;
- }
- .brick_featured_image{
- width: 100%;
- margin-top: 10px;
- }
- .brick_featured_image img{
- width: 100%;
- height: auto;
- }
- /*********************** Put this somewhere in your footer.php file **************************/
- /*********************** maybe just before <?php wp_footer(); ?> **************************/
- <script>
- jQuery( document ).ready( function( $ ) {
- $( '#container2' ).masonry( { columnWidth: 220 } );
- } );
- </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement