Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

Spun content-custom-circles.php

By: a guest on Jan 12th, 2014  |  syntax: PHP  |  size: 1.98 KB  |  views: 152  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  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="thumbnail-title 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. ?>
clone this paste RAW Paste Data