コード例 #1
0
/**
* Custom markup for gallery posts in main blog index.
*/
function bu_custom_gallery_post_format($content)
{
    global $options, $themeslug, $post;
    $root = get_template_directory_uri();
    ob_start();
    if (has_post_thumbnail() && $featured_images == '1' && !is_single()) {
        echo '<div class="featured-image">';
        echo '<a href="' . get_permalink($post->ID) . '" >';
        the_post_thumbnail();
        echo '</a>';
        echo '</div>';
    }
    ?>
	
			<div class="row">
			<div class="three columns"><?php 
    business_post_byline();
    ?>
</div>
				<div class="entry nine columns">
					<?php 
    if ($options->get($themeslug . '_post_formats') == '1') {
        ?>
						<div class="postformats"><!--begin format icon-->
							<img src="<?php 
        echo get_template_directory_uri();
        ?>
/images/formats/gallery.png" />
						</div><!--end format-icon-->
					<?php 
    }
    ?>
					<h2 class="posts_title"><a href="<?php 
    the_permalink();
    ?>
"><?php 
    the_title();
    ?>
</a></h2>
									
				<?php 
    if (!is_single()) {
        ?>
				<?php 
        $images = get_children(array('post_parent' => $post->ID, 'post_type' => 'attachment', 'post_mime_type' => 'image', 'orderby' => 'menu_order', 'order' => 'ASC', 'numberposts' => 999));
        if ($images) {
            $total_images = count($images);
            $image = array_shift($images);
            $image_img_tag = wp_get_attachment_image($image->ID, 'thumbnail');
            ?>

				<figure class="gallery-thumb">
					<a href="<?php 
            the_permalink();
            ?>
"><?php 
            echo $image_img_tag;
            ?>
</a>
					<br /><br />
					This gallery contains <?php 
            echo $total_images;
            ?>
 images
					<?php 
        }
        ?>
				</figure><!-- .gallery-thumb -->
				<?php 
    }
    ?>
				
				<?php 
    if (is_single()) {
        ?>
					<?php 
        the_content();
        ?>
				<?php 
    }
    ?>
				
				<!--Begin @Core link pages hook-->
					<?php 
    business_link_pages();
    ?>
				<!--End @Core link pages hook-->
			
				<!--Begin @Core post edit link hook-->
					<?php 
    business_edit_link();
    ?>
				<!--End @Core post edit link hook-->
				</div><!--end entry-->
			</div><!--end row-->
			<?php 
    $content = ob_get_clean();
    return $content;
}
コード例 #2
0
/**
* Check for post format type, apply filter based on post format name for easy modification.
*
* @since 3.0
*/
function business_loop_content($content)
{
    global $options, $themeslug, $post;
    //call globals
    if (is_single()) {
        $post_formats = $options->get($themeslug . '_single_post_formats');
        $featured_images = $options->get($themeslug . '_single_show_featured_images');
        $excerpts = $options->get($themeslug . '_single_show_excerpts');
    } elseif (is_archive()) {
        $post_formats = $options->get($themeslug . '_archive_post_formats');
        $featured_images = $options->get($themeslug . '_archive_show_featured_images');
        $excerpts = $options->get($themeslug . '_archive_show_excerpts');
    } else {
        $post_formats = $options->get($themeslug . '_post_formats');
        $featured_images = $options->get($themeslug . '_show_featured_images');
        $excerpts = $options->get($themeslug . '_show_excerpts');
    }
    if (get_post_format() == '') {
        $format = "default";
    } else {
        $format = get_post_format();
    }
    ?>
	<?php 
    ob_start();
    ?>
			<?php 
    if (has_post_thumbnail() && $featured_images == '1') {
        echo '<div class="featured-image">';
        echo '<a href="' . get_permalink($post->ID) . '" >';
        the_post_thumbnail();
        echo '</a>';
        echo '</div>';
    }
    ?>
	
			<!--Call @business Meta hook-->
			<div class="row">
			<div class="byline three columns"><?php 
    business_post_byline();
    ?>
</div>
				<div class="entry nine columns">
					<?php 
    if ($post_formats != '0') {
        ?>
						<div class="postformats"><!--begin format icon-->
							<img src="<?php 
        echo get_template_directory_uri();
        ?>
/images/formats/<?php 
        echo $format;
        ?>
.png" alt="formats" />
						</div><!--end format-icon-->
					<?php 
    }
    ?>
					<h2 class="posts_title"><a href="<?php 
    the_permalink();
    ?>
"><?php 
    the_title();
    ?>
</a></h2>
					<?php 
    if ($excerpts == '1' && !is_single()) {
        the_excerpt();
    } else {
        the_content();
    }
    ?>
				<!--Begin @business link pages hook-->
					<?php 
    business_link_pages();
    ?>
				<!--End @business link pages hook-->
			
				<!--Begin @business post edit link hook-->
					<?php 
    business_edit_link();
    ?>
				<!--End @business post edit link hook-->
				</div><!--end entry-->
			</div><!--end row-->
			<?php 
    $content = ob_get_clean();
    $content = apply_filters('business_post_formats_' . $format . '_content', $content);
    echo $content;
}