0

I am working on a blog (http://goo.gl/xazMe0) and this is the code of the index.php:

<div id="main-content" class="main-content row">
<div id="primary" class="content-area <?php echo $longform_site_width; ?>">
    <div id="content" class="site-content" role="main">

    <?php
        if ( have_posts() ) :
            // Start the Loop.
            while ( have_posts() ) : the_post(); 

                get_template_part( 'content', get_post_format() );

            endwhile;
            longform_paging_nav();
        else :
            get_template_part( 'content', 'none' );
        endif;
    ?>

    </div><!-- #content -->
</div><!-- #primary -->
</div><!-- #main-content -->

Issue: Instead of showing all the whole posts on the index page, immediately, I want to show only the featured images of the posts and then make these clickable to enter the post with the full content.

So, I guess, I have to remove the line

                get_template_part( 'content', get_post_format() );

and replace it by something like

                <a href="<?php the_permalink() ?>">
                <?php if ( has_post_thumbnail() ) { the_post_thumbnail();} ?>
                </a>

More or less this did work, but it totally destroyed the look of the site showing all featured images brought together like a puzzle, meaning it does not respect the HTML structure and CSS code, at all.

That means by this method I would have to rebuild everything to get it looking back to how it used to look or how it still does look inside the posts.

Is there not a more simpler way to get

                get_template_part( 'content', get_post_format () );

work the way I want it to (showing only featured image and be clickable to enter post)? Thank you in advance, mates.

1 Answer 1

2

Look in your theme folder for a file called content.php. Make a copy and rename it to anything you like, such as vega.php. Adjust the code in vega.php to your liking. Change the call in index.php to

get_template_part( 'vega', get_post_format() );
4
  • But that does change the look of the posts, right? They are fine the way they are. I just to want have the index page to show only the featured images of the posts. If I change the content.php/vega.php the design of the posts get changed and that is not needed.
    – vega
    Commented Jul 19, 2015 at 16:49
  • Don't change content.php. Make your changes in vega.php - which you edit to show the posts however you want.
    – shanebp
    Commented Jul 19, 2015 at 18:15
  • Sorry, different subjects. I understood what you are talking about, BUT I DO NOT WANT TO CHANGE POSTS or POSTS' CONTENTS. I want to change the posts' appearance on the MAIN PAGE, the index page. Right now the posts are FULLY shown, like I described in my question. If I copy and alter the renamed content.php, I will just change the look of the posts in the inside. That is not my goal. I want to change the look on the outside, that means on the main site. Instead showing full posts there, I want to have the featured image (+ title) only. The content.php/renamed.php does not help here, I guess.
    – vega
    Commented Jul 19, 2015 at 18:51
  • Alright, I did it now the way you told. :) I thought first, the content.php (or renamed.php) would affect the posts' contents, too, but it does not this way, because the single.php leads to the old content.php back and there nothing was changed. :)
    – vega
    Commented Jul 19, 2015 at 19:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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