Guest User

Spun content-custom-circles.php

a guest
Jan 11th, 2014
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.95 KB | None | 0 0
  1. <?php
  2.  
  3. /* Get custom circles */
  4.         $args = array(
  5.                 'post_type' => 'custom_circles'
  6.         );
  7.  
  8.         $custom_circles = new WP_Query( $args );
  9.  
  10.         if( $custom_circles->have_posts() ) {
  11.                 while( $custom_circles->have_posts() ) {
  12.  
  13.                         $custom_circles->the_post();
  14.  
  15.                         // Get the link
  16.                         $link = get_custom_field( 'link' );
  17.  
  18.                         //Add in "http://" if it isn't there already
  19.                         if ( strpos( $link, 'http://' ) === false ) {
  20.                             $link = 'http://' . $link;
  21.                         }
  22.  
  23.                         // I don't know how to return something useful from
  24.                         // get_custom_field that'll let me know if no image
  25.                         // has been specified, so I'm doing this elongation:
  26.                         // Convert the image to an integer
  27.                         $image_id = (int) get_custom_field( 'image:wrapper');
  28.  
  29.                         //If it's more than zero then it has matched
  30.                         if ( $image_id !== 0 ) {
  31.                                 $thumb_id = get_custom_field( 'image' );
  32.                                 $thumb = wp_get_attachment_image($thumb_id, 'home-post wp-post-image');
  33.                         }
  34.                         else {
  35.                                 $thumb = '<span class="no-thumbnail">' . esc_attr( the_title_attribute( 'echo=0' ) ) . '</span>';
  36.                                 $postclass = 'no-thumbnail';
  37.                         }
  38.  
  39.                         ?>
  40.  
  41. <article id="post-<?php the_ID(); ?>" <?php post_class( $postclass ); ?>>
  42.         <a href="<?php echo $link; ?>" title="<?php the_title() ?>" rel="bookmark">
  43.             <?php echo $thumb; ?>
  44.         </a>
  45. </article><!-- #post-<?php the_ID(); ?> -->
  46.  
  47.                                 <?php
  48.                         }
  49.                 }
  50.  
  51. ?>
Add Comment
Please, Sign In to add comment