Viewing 11 replies - 16 through 26 (of 26 total)
  • So I managed to add the featured image thumbnails to excerpts (yay!) but I’m not quite sure where to add in the permalink so the images link to their respective posts. Can you show me an example? Here’s what I have:

    <div class="post hentry ivycat-post">
    
    	<!-- This is the output of the post TITLE -->
    	<h2 class="entry-title"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
    
    	<!-- This is the output of the excerpt -->
    	<div class="entry-summary">
    	<!-- This will output of the featured image thumbnail  -->
    		<div class="featured-image">
    			<?php the_post_thumbnail( array(180,9999), array('class' => 'alignleft')); ?>
    
    		</div>
    		<?php the_excerpt(); ?>
    	</div>
    
    	<!-- This is the output of the META information -->
    	<div class="entry-utility">
    		<?php if ( count( get_the_category() ) ) : ?>
    			<span class="cat-links">
    				<?php printf( __( '<span class="%1$s">Posted in</span> %2$s', 'twentyten' ), 'entry-utility-prep entry-utility-prep-cat-links', get_the_category_list( ', ' ) ); ?>
    			</span>
    			<span class="meta-sep">|</span>
    		<?php endif; ?>
    		<?php
    			$tags_list = get_the_tag_list( '', ', ' );
    			if ( $tags_list ):
    		?>
    			<span class="tag-links">
    				<?php printf( __( '<span class="%1$s">Tagged</span> %2$s', 'twentyten' ), 'entry-utility-prep entry-utility-prep-tag-links', $tags_list ); ?>
    			</span>
    			<!--<span class="meta-sep">|</span> -->
    		<?php endif; ?>
    		<!--<span class="comments-link"><?php comments_popup_link( __( 'Leave a comment', 'twentyten' ), __( '1 Comment', 'twentyten' ), __( '% Comments', 'twentyten' ) ); ?></span>-->
    		<?php edit_post_link( __( 'Edit', 'twentyten' ), '<span class="meta-sep">|</span> <span class="edit-link">', '</span>' ); ?>
    	</div>
    </div>

    Imenara: Try adding this to functions.php

    /** Link all post thumbnails to post permalink  */
    
    add_filter( 'post_thumbnail_html', 'my_post_image_html', 10, 3 );
    
    function my_post_image_html( $html, $post_id, $post_image_id ) {
    
      $html = '<a href="' . get_permalink( $post_id ) . '" title="' . esc_attr( get_post_field( 'post_title', $post_id ) ) . '">' . $html . '</a>';
      return $html;

    :S I added it and updated the file; the screen went blank and now wordpress admin and my site are not working. I tried to hit the back button on the browser and delete the code I added, clicked update and it’s still blank. What just happened?

    Oh no, sorry. I think I missed the last closing bracket at the end. Should have been:

    /** Link all post thumbnails to post permalink  */
    
    add_filter( 'post_thumbnail_html', 'my_post_image_html', 10, 3 );
    
    function my_post_image_html( $html, $post_id, $post_image_id ) {
    
      $html = '<a href="' . get_permalink( $post_id ) . '" title="' . esc_attr( get_post_field( 'post_title', $post_id ) ) . '">' . $html . '</a>';
      return $html;
    
    }

    I normally work on my local server and make changes to functions.php and stylesheet.css in a text editor so if something goes wrong, I can easily go back and fix it.

    Can you access functions.php through a file manager via your host or FTP? If you can, add that last bracket and refresh.

    Ok back in business, but every time I add the code in it breaks the site again, bracket or no bracket. Does it make a difference that this is in my functions.php right now?

    // Replaces the excerpt "more" text by a link
    function new_excerpt_more($more) {
           global $post;
    	return '<a class="moretag" href="'. get_permalink($post->ID) . '"> Read more...</a>';
    }
    add_filter('excerpt_more', 'new_excerpt_more');
    
    function woo_display_post_image() {
    global $woo_options;
    $display_image = false;
    $width = $woo_options['woo_thumb_w'];
    $height = $woo_options['woo_thumb_h'];
    $align = $woo_options['woo_thumb_align'];
    if ( (is_single() || is_page()) && @$woo_options['woo_thumb_single'] == 'true' ) {
    $width = $woo_options['woo_single_w'];
    $height = $woo_options['woo_single_h'];
    $align = $woo_options['woo_thumb_align_single'];
    $display_image = true;
    }
    if ( get_option('woo_woo_tumblog_switch') == 'true' ) { $is_tumblog = woo_tumblog_test(); } else { $is_tumblog = false; }
    if ( $is_tumblog || ( is_single() && @$woo_options['woo_thumb_single'] == 'false' ) ) { $display_image = false; }
    if ( $display_image == true and !woo_embed('') ) { woo_image('width=' . $width . '&height=' . $height . '&class=thumbnail ' . $align); }
    } // End woo_display_post_image()

    Sorry … I’m not much help. I don’t remember what I did and why. If I get a chance, I’ll try to dissect mine and see if I can figure it out. In the meantime, someone with more experience might have an answer for you!

    Plugin Author Eric Amundson

    (@sewmyheadon)

    Hey lmenara,

    So, I think it’s a lot easier than you may think. Try wrapping your featured image in:

    <a href="<?php the_permalink(); ?>"> here is where your featured image goes </a>

    Using your entire example above, I’d change it to:

    <div class="post hentry ivycat-post">
    
    	<!-- This is the output of the post TITLE -->
    	<h2 class="entry-title"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
    
    	<!-- This is the output of the excerpt -->
    	<div class="entry-summary">
    	<!-- This will output of the featured image thumbnail  -->
    		<div class="featured-image">
    			<a href="<?php the_permalink(); ?>">
    				<?php the_post_thumbnail( array(180,9999), array('class' => 'alignleft')); ?>
    			</a>
    		</div>
    		<?php the_excerpt(); ?>
    	</div>
    
    	<!-- This is the output of the META information -->
    	<div class="entry-utility">
    		<?php if ( count( get_the_category() ) ) : ?>
    			<span class="cat-links">
    				<?php printf( __( '<span class="%1$s">Posted in</span> %2$s', 'twentyten' ), 'entry-utility-prep entry-utility-prep-cat-links', get_the_category_list( ', ' ) ); ?>
    			</span>
    			<span class="meta-sep">|</span>
    		<?php endif; ?>
    		<?php
    			$tags_list = get_the_tag_list( '', ', ' );
    			if ( $tags_list ):
    		?>
    			<span class="tag-links">
    				<?php printf( __( '<span class="%1$s">Tagged</span> %2$s', 'twentyten' ), 'entry-utility-prep entry-utility-prep-tag-links', $tags_list ); ?>
    			</span>
    			<!--<span class="meta-sep">|</span> -->
    		<?php endif; ?>
    		<!--<span class="comments-link"><?php comments_popup_link( __( 'Leave a comment', 'twentyten' ), __( '1 Comment', 'twentyten' ), __( '% Comments', 'twentyten' ) ); ?></span>-->
    		<?php edit_post_link( __( 'Edit', 'twentyten' ), '<span class="meta-sep">|</span> <span class="edit-link">', '</span>' ); ?>
    	</div>
    
    </div>

    That’s exactly what I was looking for. Worked perfectly! Thank you!

    Plugin Author Eric Amundson

    (@sewmyheadon)

    Bingo! You’re welcome. ??

    what do you charge to fix my site? I have no skill at messing with the back of the system.

    Moderator Jan Dembowski

    (@jdembowski)

    Forum Moderator and Brute Squad

    That’s not something that’s discussed here on these forums. Please consider contacting the plugin author on his own site or even post on https://jobs.wordpress.net/

    Per forum rules I am now closing this post.

    https://codex.www.ads-software.com/Forum_Welcome#Offering_to_Pay

Viewing 11 replies - 16 through 26 (of 26 total)
  • The topic ‘How to add featured image’ is closed to new replies.