simbasounds
1/10/2016 - 3:53 PM

Single Custom Post Type Template for WordPress or WordPress + Genesis.

Single Custom Post Type Template for WordPress or WordPress + Genesis.

<?php
remove_action( 'genesis_loop', 'genesis_do_loop' );
add_action( 'genesis_loop', 'custom_loop' );
function custom_loop() {
    while ( have_posts() ) : the_post();
        if ( has_post_thumbnail() ) {
            $thumb_id = get_post_thumbnail_id();
            $thumb_url = wp_get_attachment_image_src($thumb_id,'thumbnail', true);
            $my_thumb_url = $thumb_url[0];
            $my_post_thumb = "background-image: url(" . $my_thumb_url .");";
                } else {
            $my_post_thumb = "background-image: url(my-default-logo-01.png);";
        } ?>
        <article class="post" itemscope="itemscope" itemtype="http://schema.org/BlogPosting" itemprop="blogPost">
            <a class="post-image-link"  href="<?php echo get_permalink(); ?>" style="<?php echo $my_post_thumb; ?>"></a>
            <div class="entry-content">
                <h2 class="entry-title" itemprop="headline">
                    <a href="<?php echo get_permalink(); ?>" title="<?php echo get_the_title(); ?>" rel="bookmark">
                        <?php echo get_the_title(); ?>
                    </a>
                </h2>
                <?php ob_wp_content(); ?>
            </div>
        </article>
    <?php endwhile;
    wp_reset_postdata();
}
genesis();
?>