Created
October 8, 2015 07:56
-
-
Save dom082186/26b078caf747194792f3 to your computer and use it in GitHub Desktop.
WP Query
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
?> | |
<?php | |
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1; | |
$query = new WP_Query(array( | |
'post_type' => 'business_partners', | |
'posts_per_page' => -1, | |
'orderby' => 'title', | |
'order' => 'ASC', | |
)); | |
?> | |
<div class="your-class-container"> | |
<?php if ($query->have_posts()) : ?> | |
<?php $count = 0; ?> | |
<div class="your-class-row"> | |
<?php while ($query->have_posts()) : $query->the_post(); ?> | |
<?php $image = wp_get_attachment_image_src( get_post_thumbnail_id( $query->ID ), 'full' ); ?> | |
<?php $link = get_field( 'website', $query->ID ); ?> | |
<?php $new_link = ( preg_match( '#https?://#', $link ) === 0 ) ? 'http://' . $link : $link; ?> | |
<?php if( $count == 2 ) : ?> | |
</div> <!-- end of .your-class-row --> | |
<div class="your-class-row"> | |
<?php $count = 0; endif; ?> | |
<div class="your-class-details"> | |
<div class="business-partners-image" style="background: url(<?php echo $image[0]; ?>) no-repeat center; background-size: cover;"></div> | |
<div class="your-class-content"> | |
<h4><?php the_title(); ?></h4> | |
<p><?php the_content(); ?></p> | |
<p><a href="<?php echo $new_link; ?>" target="_blank"><?php echo $link; ?></a></p> | |
</div> <!-- end of .your-class-content --> | |
</div> <!-- end of .your-class-details --> | |
<?php $count++; endwhile; | |
#wp_pagenavi( array( 'query' => $query ) ); | |
wp_reset_postdata(); | |
endif; ?> | |
</div> <!-- end of .your-class-row --> | |
</div> <!-- end of .your-class-container --> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment