Remove Featured Image from Post, but not the home page.
February 2013 WordPress Theme
- GK User
- Sun Feb 17, 2013 9:04 pm
Hi,
Is it possible to stop displaying the featured image in a post without removing the featured image from the home page? I've played around with content.php and content.post.featured.php, but I'm afraid I don't know much about either.
I use a tablet to post content to my blog and the application I use connects with picasa, youtube, and others. However, when I create a post with an image it does not set it as featured, and so any photos I post will not be displayed on the home page. To work around this I use a plugin that automagically scans the post for images and then sets them as the featured image in the post. This solves the home page display, but in the post I'm left with two images, one from the post and the featured.
see here for an example of the two images
I did get close by setting the max width in the template css to 0%, but then the avatars on the comments were not displaying correctly.
any help is much appreciated.
Is it possible to stop displaying the featured image in a post without removing the featured image from the home page? I've played around with content.php and content.post.featured.php, but I'm afraid I don't know much about either.
I use a tablet to post content to my blog and the application I use connects with picasa, youtube, and others. However, when I create a post with an image it does not set it as featured, and so any photos I post will not be displayed on the home page. To work around this I use a plugin that automagically scans the post for images and then sets them as the featured image in the post. This solves the home page display, but in the post I'm left with two images, one from the post and the featured.
see here for an example of the two images
I did get close by setting the max width in the template css to 0%, but then the avatars on the comments were not displaying correctly.
- Code: Select all
img {
height: auto;
max-width: 0%;
}
any help is much appreciated.
-
- Junior Boarder
- GK User
- Sun Feb 17, 2013 9:18 pm
Hi,
Please open file layouts/content.post.featured.php and change fragment:
to:
Please open file layouts/content.post.featured.php and change fragment:
- Code: Select all
<?php if(has_post_thumbnail()) : ?>
<figure class="featured-image">
<?php the_post_thumbnail(); ?>
</figure>
<?php endif; ?>
to:
- Code: Select all
<?php if(is_home() && has_post_thumbnail()) : ?>
<figure class="featured-image">
<?php the_post_thumbnail(); ?>
</figure>
<?php endif; ?>
-
- Administrator
- GK User
- Mon Feb 18, 2013 12:44 am
perfect. thank you very much.
-
- Junior Boarder
- GK User
- Mon Feb 18, 2013 2:15 am
@dziudek
the home page and post pages are displaying correctly, but now the inset main menu category pages are missing the featured image.
can be seen here
the home page and post pages are displaying correctly, but now the inset main menu category pages are missing the featured image.
can be seen here
-
- Junior Boarder
- GK User
- Mon Feb 18, 2013 2:01 pm
if you want to don't display images only on the post pages then you should use the following code:
then the featured image won't be displayed only on the single pages. It will be displayed on the home page, category page, archive page, tag page, search page etc.
- Code: Select all
<?php if(!is_single() && has_post_thumbnail()) : ?>
<figure class="featured-image">
<?php the_post_thumbnail(); ?>
</figure>
<?php endif; ?>
then the featured image won't be displayed only on the single pages. It will be displayed on the home page, category page, archive page, tag page, search page etc.
-
- Administrator
- GK User
- Mon Feb 18, 2013 6:18 pm
thank you again for the timely response, and for your patience. that last one was what I needed.
-
- Junior Boarder
- GK User
- Tue Jul 22, 2014 12:57 pm
Hello,
Trying to remove the featured image but my code is different and cannot find what you referenced above.
Trying to remove the featured image but my code is different and cannot find what you referenced above.
- Code: Select all
<?php
/**
*
* The template fragment to show post featured image
*
**/
// disable direct access to the file
defined('GAVERN_WP') or die('Access denied');
global $gk_tpl;
$params = get_post_custom();
$params_image = isset($params['gavern-post-params-image']) ? esc_attr( $params['gavern-post-params-image'][0] ) : 'Y';
?>
<?php
// variable for the social API HTML output
$social_api_output = gk_social_api(get_the_title(), get_the_ID());
?>
<div class="gk-article-wrap">
<?php if(is_singular()) : ?>
<?php if($social_api_output != '' ): ?>
<aside id="gk-social-aside">
<?php echo $social_api_output; ?>
</aside>
<?php endif; ?>
<?php endif; ?>
<div class="gk-article-body">
<?php if((is_single() || is_page()) && $params_image == 'Y') : ?>
<?php if(has_post_thumbnail()) : ?>
<figure class="featured-image">
<?php if(is_sticky()) : ?>
<sup>
<?php _e( 'Featured', GKTPLNAME ); ?>
</sup>
<?php endif; ?>
<?php the_post_thumbnail(); ?>
<?php if(is_single() || is_page()) : ?>
<?php echo gk_post_thumbnail_caption(); ?>
<?php endif; ?>
</figure>
<?php
// if there is a Featured Video
elseif(get_post_meta(get_the_ID(), "_gavern-featured-video", true) != '') :
?>
<div class="gk-video-wrap">
<?php echo get_post_meta(get_the_ID(), "_gavern-featured-video", true); ?>
</div>
<?php endif; ?>
<?php elseif(!(is_single() || is_page())) : ?>
<?php if($params_image == 'Y') : ?>
<?php if(has_post_thumbnail()) : ?>
<figure class="featured-image">
<?php if(is_sticky()) : ?>
<sup>
<?php _e( 'Featured', GKTPLNAME ); ?>
</sup>
<?php endif; ?>
<a href="<?php the_permalink(); ?>">
<?php the_post_thumbnail(); ?>
</a>
<?php if(is_single() || is_page()) : ?>
<?php echo gk_post_thumbnail_caption(); ?>
<?php endif; ?>
</figure>
<?php
// if there is a Featured Video
elseif(get_post_meta(get_the_ID(), "_gavern-featured-video", true) != '') :
?>
<div class="gk-video-wrap">
<?php echo get_post_meta(get_the_ID(), "_gavern-featured-video", true); ?>
</div>
<?php endif; ?>
<?php endif; ?>
<?php endif; ?>
-
- Fresh Boarder
- GK User
- Tue Jul 22, 2014 2:55 pm
@samuelkingme - do you want to totally remove the featured image or want to hide it on pages other than homepage?
-
- Administrator
8 posts
• Page 1 of 1