WordPress.org

Ready to get started?Download WordPress

Forums

Display Featured Image in index.php (7 posts)

  1. mcunha98
    Member
    Posted 10 months ago #

    I'm trying to create my own theme (based on standards of WP).

    Many things are right, but the home page list that I want no ! I change the default list of site, to show

    thumb
    title
    post data
    category

    The Thumb option, based in Featured Image dont work. If I use has_thumbmail always receive FALSE (yes, I edit some post and choose an image was Feature Image por post).

    I saw the documentation about it, and change but nothing. Links that I used:

    https://codex.wordpress.org/Function_Reference/add_theme_support
    http://www.sitepoint.com/how-to-add-featured-image-thumbnails-to-your-wordpress-theme/

    The code from template.php

    <?php if ( 'post' == get_post_type() ) : ?>
    <div class="entry-meta">
    <?php
    echo('Has Thumbnail: ' . has_post_thumbnail());
    if ( has_post_thumbnail() )
    {
    the_post_thumbnail();
    }
    ?>
    <?php twentyeleven_posted_on(); ?>
    </div><!-- .entry-meta -->
    <?php endif; ?>

    [Moderator Note: Please post code & markup between backticks or use the code button. Your posted code may now have been permanently damaged by the forum's parser.]

    Some idea ???

  2. Sunder Deep Dasna
    Member
    Posted 10 months ago #

    Are you working on the index.php or template.php?

  3. mcunha98
    Member
    Posted 10 months ago #

    I'm working on template.php

  4. Sunder Deep Dasna
    Member
    Posted 10 months ago #

    You want to show feature image in homepage or inner page.

  5. mcunha98
    Member
    Posted 10 months ago #

    In homepage

  6. Sunder Deep Dasna
    Member
    Posted 10 months ago #

    How do you include the template.php in index.php?

  7. mcunha98
    Member
    Posted 10 months ago #

    I found this piece of code, and understood that I need to change the template page:

    My template is based on Twenty Eleven default theme:

    <?php if ( have_posts() ) : ?>
    
    				<?php twentyeleven_content_nav( 'nav-above' ); ?>
    
    				<?php /* Start the Loop */ ?>
    				<?php while ( have_posts() ) : the_post(); ?>
    					<?php get_template_part( 'content', get_post_format() ); ?>
    				<?php endwhile; ?>
    
    				<?php twentyeleven_content_nav( 'nav-below' ); ?>
    
    			<?php else : ?>

    [Moderator Note: Please post code & markup between backticks or use the code button. Your posted code may now have been permanently damaged by the forum's parser.]

Reply

You must log in to post.

About this Topic