Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

My thumbnails are not showing up in my custom post type when I do a query, however they show in the single.php file.

I have added 'supports' => array('title','editor','author','thumbnail','excerpt','comments') to the function so I know its not that issue. I am gettin the rest of the data on the query as viewable below but the image should be above the text: enter image description here

I am not having this issue in the single page with the featured image showing up :

enter image description here

I am registering my custom post type as so:

add_action('init', 'video_custom_init');    

/* SECTION - video_custom_init */
function video_custom_init()
{
    // the remainder code goes here
}
/* #end SECTION - video_custom_init --*/

// The following is all the names, in our tutorial, we use "video"
    $labels = array(
        'name' => _x('videos', 'post type general name'),
        'singular_name' => _x('video', 'post type singular name'),
        'add_new' => _x('Add New', 'video'),
        'add_new_item' => __('Add New video'),
        'edit_item' => __('Edit video'),
        'new_item' => __('New video'),
        'view_item' => __('View video'),
        'search_items' => __('Search videos'),
        'not_found' =>  __('No videos found'),
        'not_found_in_trash' => __('No videos found in Trash'),
        'parent_item_colon' => '',
        'menu_name' => 'video'
    );

    // Some arguments and in the last line 'supports', we say to WordPress what features are supported on the video post type
    $args = array(
        'labels' => $labels,
        'public' => true,
        'publicly_queryable' => true,
        'show_ui' => true,
        'show_in_menu' => true,
        'query_var' => true,
        'rewrite' => true,
        'capability_type' => 'post',
        'has_archive' => true,
        'hierarchical' => false,
        'menu_position' => null,
        'supports' => array('title','editor','author','thumbnail','excerpt','comments')
    );

    // We call this function to register the custom post type
    register_post_type('video',$args);

I am pretty confused about what the issue would be. It is probably something really simple.

Query used to display custom post.

<?php if ( have_posts() ) : ?>

<?php $args = array( 'post_type' => 'video', 'posts_per_page' => 3 );
            $loop = new WP_Query( $args );
                while ( $loop->have_posts() ) : $loop->the_post(); 

                    get_template_part( '/templates/content-3col');

                    endwhile;?>

            <?php endif; ?>

and the code in col3.php

<div class="col-md-4">
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
    <header class="page-header" style="border-bottom:none; margin-bottom:0;">
        <?php if ( 'post' == get_post_type() ) : ?>
        <div style="margin-bottom:5px;">
        <a href="<?php the_permalink(); ?>" rel="bookmark">
    <?php   if ( has_post_thumbnail() ) {
            the_post_thumbnail('col-6-thumb');

                } ?>
        </a>
        </div>
        <?php endif; ?>
            </header>


        <div class="article-info">
        <div class="article-date"><h3><?php the_time('M jS') ?></h3></div>
        <div class="articletitle"><h3><a href="<?php the_permalink(); ?>" rel="bookmark"><?php the_title(); ?></a></h3><p>by <?php the_author() ?></p></div>
                </div>  
    </article><!-- #post-## --> 
</div>
share|improve this question
    
Can you paste the code for the query you are using to display on the front end ? Not the single page code. –  Subharanjan Dec 9 '13 at 14:19
    
@Subharanjan added above –  user2960468 Dec 9 '13 at 14:22
    
Can you please show me the code for get_template_part( '/templates/content-3col'); themplate file ?? :) –  Subharanjan Dec 9 '13 at 14:23
    
@Subharanjan opps sorry, added above –  user2960468 Dec 9 '13 at 14:25
add comment

1 Answer

up vote 0 down vote accepted
<div class="col-md-4">
    <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
        <header class="page-header" style="border-bottom:none; margin-bottom:0;">
            <div style="margin-bottom:5px;">
                <a href="<?php the_permalink(); ?>" rel="bookmark">
                <?php   if ( has_post_thumbnail() ) {
                the_post_thumbnail('col-6-thumb');
                } ?>
                </a>
            </div>
        </header>
        <div class="article-info">
            <div class="article-date"><h3><?php the_time('M jS') ?></h3></div>
            <div class="articletitle"><h3><a href="<?php the_permalink(); ?>" rel="bookmark"><?php the_title(); ?></a></h3><p>by <?php the_author() ?></p></div>
        </div>  
    </article><!-- #post-## --> 
</div>

Can you put this code inside the template file that your including using get_template_part( '/templates/content-3col');

Note: As you are querying for post type "video", you should check for post type as "video" instead. Here you are checking for "post" <?php if ( 'post' == get_post_type() ) : ?> which was causing the problem. I have just removed that.

share|improve this answer
    
brillant. It works. It was a silly mistake by me. Thanks Subharanjan. Ill accept ur answer when the time limit runs out –  user2960468 Dec 9 '13 at 14:31
    
after note section you answer is complete now. –  Ravs Dec 9 '13 at 14:41
1  
@Ravs: Thanks !! By the time I got the edit suggestion, I had already added the note. :) –  Subharanjan Dec 9 '13 at 14:46
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.