WordPress.org

Ready to get started?Download WordPress

Forums

zBench theme. What does this code do in the functions file? (4 posts)

  1. sstruemph
    Member
    Posted 2 years ago #

    I had to remove everything after this line to fix an issue with eShop.
    add_theme_support( 'post-thumbnails' );

    I understand that adds support for the "featured image" in posts but I was wondering what the rest does... especially the part that adds an "a href" link. Mostly I am curious if removing it is a good idea or not.

    The issue with eShop was that the code here adds an extra link and wraps it around code that eShop outputs too. So it is then redundant, won't validate, and breaks the layout in some browsers.

    // This theme uses post thumbnails
    	add_theme_support( 'post-thumbnails' );
    	add_image_size( 'extra-featured-image', 620, 200, true );
    	function zbench_featured_content($content) {
    		if (is_home() || is_archive()) {
    			the_post_thumbnail( 'extra-featured-image' );
    		}
    		return $content;
    	}
    	add_filter( 'the_content', 'zbench_featured_content',1 );
    	function zbench_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;
    	}
    	add_filter( 'post_thumbnail_html', 'zbench_post_image_html', 10, 3 );
  2. esmi
    Theme Diva & Forum Moderator
    Posted 2 years ago #

    I had to remove everything after this line to fix an issue with eShop.

    Just to elaborate on this - the issue isn't within eShop. It's within the theme. eShop works quite happily with the WordPress featured image functionality (and, in fact, uses the same functionality itself) in (say) Twenty Eleven.

    From what I can tell, the issue is with the zbench_post_image_html() function which is effectively rewriting the post_thumbnail output - thus rendering the theme incompatible with any plugin that uses featured images.

  3. sstruemph
    Member
    Posted 2 years ago #

    Thank you, esmi, for the clarification. Didn't mean for that sound like there was an issue with the eShop plugin itself :)

  4. esmi
    Theme Diva & Forum Moderator
    Posted 2 years ago #

    No probs. Just making sure that anyone who reads this topic over the next months/years gets the full picture. It is likely that other plugins may be affected, so this topic may help them to track down the cause. In the meantime, I've responded to your last post on the quirm.net forum. :-)

Topic Closed

This topic has been closed to new replies.

About this Topic