Support » Themes and Templates » Using Meta_key to set has_post_thumbnail() to true

  • I using pinboard theme and am trying to add a Meta_key (thumbnail_html) to set has_post_thumbnail() to true.

    I have tried using

    if( ! is_singular() && has_post_thumbnail() && ! has_post_format( 'gallery' ) && ! has_post_format( 'image' ) && ! has_post_format( 'status' ) && ! has_post_format( 'video' )  && ! Meta_key=thumbnail_html  )
    		$classes[] = 'has-thumbnail';

    as well as

    if( ! is_singular() && has_post_thumbnail() && ! has_post_format( 'gallery' ) && ! has_post_format( 'image' ) && ! has_post_format( 'status' ) && ! has_post_format( 'video' )  && ! Meta_key ("thumbnail_html")  )
    		$classes[] = 'has-thumbnail'

    However both produce an error.

    The full code is

    function pinboard_post_class( $classes, $class, $post_id ) {
    	global $pinboard_count;
    	if( ! isset( $pinboard_count ) )
    		$pinboard_count = 0;
    	$pinboard_count++;
    	$classes[] = 'column';
    	if( pinboard_is_teaser() ) {
    		global $pinboard_page_template;
    		if( isset( $pinboard_page_template ) ) {
    			if( 'template-blog.php' == $pinboard_page_template || 'template-portfolio-right-sidebar.php' == $pinboard_page_template )
    				$classes[] = 'twocol';
    			elseif( 'template-blog-full-width.php' == $pinboard_page_template || 'template-portfolio.php' == $pinboard_page_template )
    				$classes[] = 'threecol';
    			elseif( 'template-blog-four-col.php' == $pinboard_page_template || 'template-portfolio-four-col.php' == $pinboard_page_template )
    				$classes[] = 'fourcol';
    			elseif( 'template-blog-left-sidebar.php' == $pinboard_page_template || 'template-portfolio-left-sidebar.php' == $pinboard_page_template )
    				$classes[] = 'twocol';
    			elseif( 'template-blog-no-sidebars.php' == $pinboard_page_template || 'template-portfolio-no-sidebars.php' == $pinboard_page_template )
    				$classes[] = 'twocol';
    		} elseif( is_category( pinboard_get_option( 'portfolio_cat' ) ) || ( is_category() && cat_is_ancestor_of( pinboard_get_option( 'portfolio_cat' ), get_queried_object() ) ) ) {
    			if( 2 == pinboard_get_option( 'portfolio_columns' ) )
    				$classes[] = 'twocol';
    			elseif( 3 == pinboard_get_option( 'portfolio_columns' ) )
    				$classes[] = 'threecol';
    			elseif( 4 == pinboard_get_option( 'portfolio_columns' ) )
    				$classes[] = 'fourcol';
    		} elseif( 'full-width' == pinboard_get_option( 'layout' ) || 'no-sidebars' == pinboard_get_option( 'layout' ) ) {
    			if( 2 == pinboard_get_option( 'layout_columns' ) )
    				$classes[] = 'twocol';
    			elseif( 3 == pinboard_get_option( 'layout_columns' ) )
    				$classes[] = 'threecol';
    			elseif( 4 == pinboard_get_option( 'layout_columns' ) )
    				$classes[] = ( 'no-sidebars' == pinboard_get_option( 'layout' ) ? 'threecol' : 'fourcol' );
    		} else {
    			if( 2 == pinboard_get_option( 'layout_columns' ) )
    				$classes[] = 'onecol';
    			elseif( 3 == pinboard_get_option( 'layout_columns' ) )
    				$classes[] = 'twocol';
    			elseif( 4 == pinboard_get_option( 'layout_columns' ) )
    				$classes[] = 'threecol';
    		}
    	} else {
    		$classes[] = 'onecol';
    	}
    	if( ! is_singular() && has_post_thumbnail() && ! has_post_format( 'gallery' ) && ! has_post_format( 'image' ) && ! has_post_format( 'status' ) && ! has_post_format( 'video' )  )
    		$classes[] = 'has-thumbnail';
    	return $classes;
    }
    endif;
    
    add_filter( 'post_class', 'pinboard_post_class', 10, 3 );
    
    if ( ! function_exists( 'pinboard_is_teaser' ) )

  • The topic ‘Using Meta_key to set has_post_thumbnail() to true’ is closed to new replies.