Advertisement
Guest User

Spun content-custom-circles.php

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