WordPress.org

Support

Support » Themes and Templates » zBench theme. What does this code do in the functions file?

zBench theme. What does this code do in the functions file?

  • 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 );
Viewing 3 replies - 1 through 3 (of 3 total)
  • esmi

    @esmi

    Forum Moderator

    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.

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

    esmi

    @esmi

    Forum Moderator

    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. 🙂

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘zBench theme. What does this code do in the functions file?’ is closed to new replies.
Skip to toolbar