Advertisement
Guest User

Spun Custom Circles index.php

a guest
Jan 11th, 2014
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 4.62 KB | None | 0 0
  1. <?php
  2. /**
  3.  * The main template file.
  4.  *
  5.  * This is the most generic template file in a WordPress theme
  6.  * and one of the two required files for a theme (the other being style.css).
  7.  * It is used to display a page when nothing more specific matches a query.
  8.  * E.g., it puts together the home page when no home.php file exists.
  9.  * Learn more: http://codex.wordpress.org/Template_Hierarchy
  10.  *
  11.  * @package Spun
  12.  */
  13.  
  14. get_header(); ?>
  15.  
  16.         <div id="primary" class="content-area">
  17.             <div id="content" class="site-content" role="main">
  18.             <?php if ( is_home() && ! is_paged() ) : ?>
  19.                 <h2 class="site-description"><?php bloginfo( 'description' ); ?></h2>
  20.             <?php endif; ?>
  21.             <?php if ( have_posts() ) : ?>
  22.  
  23.                 <?php /* Start the Loop */ ?>
  24.  
  25.                 <?php while ( have_posts() ) : the_post(); ?>
  26.  
  27.                     <?php
  28.                         /* Include the Post-Format-specific template for the content.
  29.                          * If you want to overload this in a child theme then include a file
  30.                          * called content-___.php (where ___ is the Post Format name) and that will be used instead.
  31.                          */
  32.                         get_template_part( 'content', 'home' );
  33.                     ?>
  34.  
  35.                 <?php endwhile; ?>
  36.  
  37.                                 <?php
  38.  
  39.                                 /* Get custom circles */
  40.                                         $args = array(
  41.                                                 'post_type' => 'custom_circles'
  42.                                         );
  43.  
  44.                                         $custom_circles = new WP_Query( $args );
  45.  
  46.                                         if( $custom_circles->have_posts() ) {
  47.                                                 while( $custom_circles->have_posts() ) {
  48.  
  49.                                                         $custom_circles->the_post();
  50.  
  51.                                                         // Get the link
  52.                                                         $link = get_custom_field( 'link' );
  53.  
  54.                                                         //Add in "http://" if it isn't there already
  55.                                                         if ( strpos( $link, 'http://' ) === false ) {
  56.                                                             $link = 'http://' . $link;
  57.                                                         }
  58.  
  59.                                                         // I don't know how to return something useful from
  60.                                                         // get_custom_field that'll let me know if no image
  61.                                                         // has been specified, so I'm doing this elongation:
  62.                                                         // Convert the image to an integer
  63.                                                         $image_id = (int) get_custom_field( 'image:wrapper');
  64.  
  65.                                                         //If it's more than zero then it has matched
  66.                                                         if ( $image_id !== 0 ) {
  67.                                                                 $thumb_id = get_custom_field( 'image' );
  68.                                                                 $thumb = wp_get_attachment_image($thumb_id, 'home-post wp-post-image');
  69.                                                         }
  70.                                                         else {
  71.                                                                 $thumb = '<span class="no-thumbnail">' . esc_attr( the_title_attribute( 'echo=0' ) ) . '</span>';
  72.                                                                 $postclass = 'no-thumbnail';
  73.                                                         }
  74.  
  75.                                                         ?>
  76.  
  77.                                 <article id="post-<?php the_ID(); ?>" <?php post_class( $postclass ); ?>>
  78.                                         <a href="<?php echo $link; ?>" title="<?php the_title() ?>" rel="bookmark">
  79.                                             <?php echo $thumb; ?>
  80.                                         </a>
  81.                                 </article><!-- #post-<?php the_ID(); ?> -->
  82.  
  83.                                                                 <?php
  84.                                                         }
  85.                                                 }
  86.                                 ?>
  87.                 <?php spun_content_nav( 'nav-below' ); ?>
  88.  
  89.             <?php elseif ( current_user_can( 'edit_posts' ) ) : ?>
  90.  
  91.                 <?php get_template_part( 'content', 'none' ); ?>
  92.  
  93.             <?php endif; ?>
  94.  
  95.             </div><!-- #content .site-content -->
  96.         </div><!-- #primary .content-area -->
  97.  
  98. <?php get_sidebar(); ?>
  99. <?php get_footer(); ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement