Support » Fixing WordPress » Custom Post Type: Featured Image Problem

  • Resolved Sr Interactive Developer

    (@sr-interactive-developer)


    I need someone’s help with this one. I have created a custom post-type and have allowed ‘thumbnails’ to be used. I then created a new page and assigned the page-template to a php script within my theme.

    In my ‘register_post_type’ call arguments I am setting this:
    'supports' => array( 'title', 'editor', 'excerpt', 'thumbnail' )

    Also in my functions.php I have included the following:

    add_theme_support( 'post-thumbnails' );

    I am then using the following in my custom page-template file:

    $loop = new WP_Query( array( 'post_type' => 'work_type', 'posts_per_page' => 9 ) );
    while ( $loop->have_posts() ) : $loop->the_post();
    get_the_post_thumbnail( the_ID(), 'thumbnail' );
    endwhile;

    The html that get’s returned is the page’s ID. Any ideas how I can get the image returned and not the ID?

    Thank you for your assistance!

Viewing 1 replies (of 1 total)
  • Sr Interactive Developer

    (@sr-interactive-developer)

    So it looks like I created the issue by using ‘$id’ variable within my loop statement.

    ex:

    $loop = new WP_Query( array( 'post_type' => 'work_type', 'posts_per_page' => 9 ) );
    while ( $loop->have_posts() ) : $loop->the_post();
    $id // This created the issue.
    get_the_post_thumbnail( the_ID(), 'thumbnail' );
    endwhile;

Viewing 1 replies (of 1 total)
  • The topic ‘Custom Post Type: Featured Image Problem’ is closed to new replies.