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.

I have my blog page here on a website I created, however I'm not understanding quite where to find the code to get rid of the images on my child theme. I'm using code from Twenty Ten and have set my own BLOG template page up but it's not working so I'm obviously editing the wrong file.

So isn't loop.php the file I'd want to edit to take out these images on the main blog page?

<?php /* How to display all other posts. */ ?>

    <?php else : ?>
        <div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
            <h2 class="entry-title"><a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'twentyten' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php the_title(); ?></a></h2>



    <?php if ( is_archive() || is_search() ) : // Only display excerpts for archives and search. ?>
            <div class="entry-summary">
                <?php the_excerpt(); ?>
            </div><!-- .entry-summary -->
    <?php else : ?>
            <div class="entry-content">
                <?php the_content( __( 'Continue reading <span class="meta-nav">&rarr;</span>', 'twentyten' ) ); ?>
                <?php wp_link_pages( array( 'before' => '<div class="page-link">' . __( 'Pages:', 'twentyten' ), 'after' => '</div>' ) ); ?>
            </div><!-- .entry-content -->
    <?php endif; ?>


        </div><!-- #post-## --> 

But I don't know where it is that shows the images. These are just images I've added to the blog entries throughout the content.

Help is appreciated!

share|improve this question
    
Are those featured images, or are they images in the content? If the latter, then you would have to either remove them from the page, add a filter to disable their display on the home page, or use the_excerpt() instead of the_content() (and it might be that the_excerpt() will still display the images). –  Pat J May 21 '13 at 20:21
    
Assuming the latter (having re-read the question), I've posted an answer below. –  Pat J May 21 '13 at 20:28
add comment

2 Answers

up vote 1 down vote accepted

It sounds like you want to display only the excerpts on your blog home page. To do that, add is_home() to your conditional statement so that it looks like this:

<?php if ( is_archive() || is_search() || is_home() ) : // Only display excerpts for archives, search and blog home page. ?>

You can read more about what is_home() does here.

share|improve this answer
    
Pat J's answer is better if you want to keep the full content of each entry visible on your blog's home page. –  Burgon May 21 '13 at 20:30
1  
Also, per the codex, the_excerpt() strips out any HTML tags and graphics. –  Burgon May 21 '13 at 20:34
    
Yes, I just re-read the Codex page and saw that it strips out HTML & graphics. Must try to remember that... –  Pat J May 21 '13 at 20:36
    
Thnaks for the feedback Pat J and Burgon! I've been able to do what I need to do for the blog. It's just a simple/basic blog anyways so this is perfect! Thanks Burgon! I'll keep all this in mind for the next blog. –  kia4567 May 21 '13 at 21:44
add comment

If the images are part of the content of the page, you can try this:

add_filter( 'the_content', 'wpse100248_strip_images' );
function wpse100248_strip_images( $content ) {
    if( is_home() || is_front_page() ) {
        $find = '/<img [^>]*>/';
        $repl = '';
        $content = preg_replace( $find, $repl, $content);
    }
    return $content;
}

This should remove <img ...> tags from the post/page content, but only on the site's front page or home page.

References

Codex: is_front_page() & is_home()
PHP's preg_replace()

share|improve this answer
1  
Also: I personally would probably insert this code into the theme's functions.php, since it's about presentation, but have a look at this Q&A and follow your heart. –  Pat J May 21 '13 at 20:35
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.