Advertisement
Guest User

Spun content-custom-circles.php

a guest
Jan 12th, 2014
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.38 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.  
  12.                 while( $custom_circles->have_posts() ) {
  13.  
  14.                         $custom_circles->the_post();
  15.  
  16.                         // Get the link
  17.                         $link = get_custom_field( 'link' );
  18.  
  19.                         //Add in "http://" if it isn't there already
  20.                         if ( strpos( $link, 'http://' ) === false ) {
  21.                             $link = 'http://' . $link;
  22.                         }
  23.  
  24.                         // I don't know how to return something useful from
  25.                         // get_custom_field that'll let me know if no image
  26.                         // has been specified, so I'm doing this elongation:
  27.                         // Convert the image to an integer
  28.                         $image_id = (int) get_custom_field( 'image:wrapper');
  29.  
  30.                         //If it's more than zero then it has matched
  31.                         if ( $image_id !== 0 ) {
  32.                                 $thumb_id = get_custom_field( 'image' );
  33.                                 $thumb = wp_get_attachment_image($thumb_id, 'home-post wp-post-image');
  34.                         }
  35.                         else {
  36.                                 $thumb = '<span class="thumbnail-title no-thumbnail">' . esc_attr( the_title_attribute( 'echo=0' ) ) . '</span>';
  37.                                 $postclass = 'no-thumbnail';
  38.                         }
  39.  
  40.                         // Get the order field
  41.                         $order = get_custom_field( 'order' );
  42.                        
  43.                         // If the order has been set
  44.                         if ( !empty( $order ) ) {
  45.                                $order = "data-order='$order'";
  46.                         } else {
  47.                                $order = "";
  48.                         }
  49.                         ?>
  50.  
  51. <article id="post-<?php the_ID(); ?>" <?php post_class( $postclass ); echo $order; ?>>
  52.         <a href="<?php echo $link; ?>" title="<?php the_title() ?>" rel="bookmark">
  53.             <?php echo $thumb; ?>
  54.         </a>
  55. </article><!-- #post-<?php the_ID(); ?> -->
  56.  
  57.                                 <?php
  58.                         }
  59.  
  60.                 }
  61.  
  62. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement