WordPress.org

Ready to get started?Download WordPress

Forums

Replace Featured Image with Video
Featured Video Box Missing for Posts (68 posts)

  1. Florence
    Member
    Posted 1 year ago #

    Can you post a snippet of the code from your theme that is displaying the featured image on post pages (single.php)?

  2. souwar
    Member
    Posted 1 year ago #

    Hello and thank you for the fast reply, this is my single.php

    <?php get_header(); ?>
    
    <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    
    <!-- pk start post -->
    <div class="pk_entry pk_entry_single pk_clearfix">
    <?php if (has_post_thumbnail()) : ?>
    
    <div class="pk_image">
    	<div class="pk_image_wrapper">
    		<?php global $pk_sidebar; the_post_thumbnail((($pk_sidebar != 'pk_full_width_page') ? 'thumb-blog' : 'full-blog')); ?>
    		<span class="pk_image_button_back_ground"></span>
    		<span class="pk_image_button_icon"></span>
    	</div>
    	<img src="<?php echo PK_THEME_DIR; ?>/parkerandkent2011/images/theme/image_icons/images_shadow.png" class="pk_image_shadow" alt="" />
    </div>
    <?php endif; ?>
    
    <div class="pk_entry_meta">
    	<div>
    		<?php _e('By:', 'pk_text_domain_front'); ?> <?php the_author_posts_link(); ?>
    		<?php echo get_the_date(); ?>
    		<a href="#" title=""><?php _e('Categories', 'pk_text_domain_front'); ?></a>
    <?php if (pk_get_options('pk_general_options', 'general_show_add_this') == 'true') : ?>
    		<div class="pk_add_this">
    			<div class="addthis_toolbox addthis_default_style">
    				<p style="margin:10px 0px 5px 0px;"><a></a></p>
    				<a></a>
    				<a></a>
    			</div>
    			<script type="text/javascript">var addthis_config = {"data_track_clickback":true};</script>
    			<script type="text/javascript" src="http://s7.addthis.com/js/250/addthis_widget.js#pubid=<?php echo pk_get_options('pk_general_options', 'general_add_this_username'); ?>"></script>
    		</div>
    <?php endif; ?>
    	</div>
    <?php if (get_the_category() || get_the_tags()) : ?>
    	<div class="pk_categories_tags_wrapper">
    		<div class="pk_categories_tags">
    <?php if (get_the_category()) : ?>
    			<div class="pk_categories">
    				<h4><?php _e('Categories', 'pk_text_domain_front'); ?></h4>
    				<ul class="pk_arrow_list">
    <?php $pk_categories = get_the_category(get_the_ID()); foreach ($pk_categories as $pk_category) : ?>
    
    <li><a> term_id); ?>" title="<?php echo $pk_category -> cat_name; ?>"<?php if (get_query_var('category_name') == $pk_category -> category_nicename) echo ' class="pk_current"'; ?>><?php echo $pk_category -> cat_name; ?></a></li>
    <?php endforeach; ?>
    
    			</div>
    <?php endif; ?>
    <?php if (get_the_tags()) : ?>
    			<div class="pk_tags">
    				<h4><?php _e('Tags', 'pk_text_domain_front'); ?></h4>
    				<ul class="pk_arrow_list">
    <?php $pk_tags = get_the_tags(); foreach ($pk_tags as $pk_tag) : ?>
    
    <li><a> term_id); ?>" title="<?php echo $pk_tag -> name ; ?>"<?php if (get_query_var('category_name') == $pk_tag -> name ) echo ' class="pk_current"'; ?>><?php echo $pk_tag -> name ; ?></a></li>
    <?php endforeach; ?>
    
    			</div>
    <?php endif; ?>
    		</div>
    		<span class="pk_arrow"></span>
    	</div>
    <?php endif; ?>
    </div>
    
    <div class="pk_entry_content">
    <?php the_content(); ?>
    <?php pk_add_link_pages(); ?>
    <?php pk_add_previous_next_post_links(); ?>
    </div>
    
    </div>
    
    <!-- pk end post -->
    
    <!-- pk start entry comments -->
    <?php comments_template(); ?>
    <!-- pk end entry comments -->
    <?php endwhile; ?>
    <?php endif; ?>
    
    <?php get_footer(); ?>

    [Moderator Note: Please post code or markup snippets between backticks or use the code button. Or better still - use a pastebin. As it stands, your posted code may now have been permanently damaged/corrupted by the forum's parser.]

  3. souwar
    Member
    Posted 1 year ago #

    <?php get_header(); ?>
    
    <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    
    <!-- pk start post -->
    <div class="pk_entry pk_entry_single pk_clearfix">
    <?php if (has_post_thumbnail()) : ?>
    
    <div class="pk_image">
    	<div class="pk_image_wrapper">
    		<?php global $pk_sidebar; the_post_thumbnail((($pk_sidebar != 'pk_full_width_page') ? 'thumb-blog' : 'full-blog')); ?>
    		<span class="pk_image_button_back_ground"></span>
    		<span class="pk_image_button_icon"></span>
    	</div>
    	<img src="<?php echo PK_THEME_DIR; ?>/parkerandkent2011/images/theme/image_icons/images_shadow.png" class="pk_image_shadow" alt="" />
    </div>
    <?php endif; ?>
    
    <div class="pk_entry_meta">
    	<div>
    		<?php _e('By:', 'pk_text_domain_front'); ?> <?php the_author_posts_link(); ?>
    		<?php echo get_the_date(); ?>
    		<a href="#" class="pk_button_categories" title=""><?php _e('Categories', 'pk_text_domain_front'); ?></a>
    <?php if (pk_get_options('pk_general_options', 'general_show_add_this') == 'true') : ?>
    		<div class="pk_add_this">
    			<div class="addthis_toolbox addthis_default_style">
    				<p style="margin:10px 0px 5px 0px;"><a class="addthis_button_google_plusone" g:plusone:size="small"></a></p>
    				<a class="addthis_button_facebook" g:facebook:size="small" style="float:left;" ></a>
    				<a class="addthis_button_twitter" g:twitter:size="small" style="float:left;" ></a>
    			</div>
    			<script type="text/javascript">var addthis_config = {"data_track_clickback":true};</script>
    			<script type="text/javascript" src="http://s7.addthis.com/js/250/addthis_widget.js#pubid=<?php echo pk_get_options('pk_general_options', 'general_add_this_username'); ?>"></script>
    		</div>
    <?php endif; ?>
    	</div>
    <?php if (get_the_category() || get_the_tags()) : ?>
    	<div class="pk_categories_tags_wrapper">
    		<div class="pk_categories_tags">
    <?php if (get_the_category()) : ?>
    			<div class="pk_categories">
    				<h4><?php _e('Categories', 'pk_text_domain_front'); ?></h4>
    				<ul class="pk_arrow_list">
    <?php $pk_categories = get_the_category(get_the_ID()); foreach ($pk_categories as $pk_category) : ?>
    					<li><a href="<?php echo get_category_link($pk_category -> term_id); ?>" title="<?php echo $pk_category -> cat_name; ?>"<?php if (get_query_var('category_name') == $pk_category -> category_nicename) echo ' class="pk_current"'; ?>><?php echo $pk_category -> cat_name; ?></a></li>
    <?php endforeach; ?>
    				</ul>
    			</div>
    <?php endif; ?>
    <?php if (get_the_tags()) : ?>
    			<div class="pk_tags">
    				<h4><?php _e('Tags', 'pk_text_domain_front'); ?></h4>
    				<ul class="pk_arrow_list">
    <?php $pk_tags = get_the_tags(); foreach ($pk_tags as $pk_tag) : ?>
    					<li><a href="<?php echo get_tag_link($pk_tag -> term_id); ?>" title="<?php echo $pk_tag -> name ; ?>"<?php if (get_query_var('category_name') == $pk_tag -> name ) echo ' class="pk_current"'; ?>><?php echo $pk_tag -> name ; ?></a></li>
    <?php endforeach; ?>
    				</ul>
    			</div>
    <?php endif; ?>
    		</div>
    		<span class="pk_arrow"></span>
    	</div>
    <?php endif; ?>
    </div>
    
    <div class="pk_entry_content">
    <?php the_content(); ?>
    <?php pk_add_link_pages(); ?>
    <?php pk_add_previous_next_post_links(); ?>
    </div>
    
    </div>
    
    <!-- pk end post -->
    
    <!-- pk start entry comments -->
    <?php comments_template(); ?>
    <!-- pk end entry comments -->
    <?php endwhile; ?>
    <?php endif; ?>
    
    <?php get_footer(); ?>
  4. Florence
    Member
    Posted 1 year ago #

    Okay so I'm not an expert (at all!) but you need to create a conditional funtion: if featured video is there, display it, if not, display the featured image. For me, this was the code that showed my featured image:

    <?php if (  (function_exists('has_post_thumbnail')) && (has_post_thumbnail())  ) { /* if post has a thumbnail */ ?>
    				<?php the_post_thumbnail('post-thumb', array('class' => 'post-thumb')); ?>
    				<?php } ?>

    I added a part that calls the featured video, and added the part that calls the featured image after it. It is slightly modified so pay attention where all parts go.

    <?php
    if(get_post_meta(get_the_ID(), "_related-video", true) != ''){
       // show the video embed code if there is one
        echo get_post_meta(get_the_ID(), "_related-video", true);
    }else{
       if (  (function_exists('has_post_thumbnail')) && (has_post_thumbnail())  ) {
        // show the image thumb if there is one, and the post does not have a video
        the_post_thumbnail('post-thumb', array('class' => 'post-thumb'));
       }
    }
    ?>

    For you, this is the part that displays your featured image:

    <?php if (has_post_thumbnail()) : ?>
    
    <div class="pk_image">
    	<div class="pk_image_wrapper">
    		<?php global $pk_sidebar; the_post_thumbnail((($pk_sidebar != 'pk_full_width_page') ? 'thumb-blog' : 'full-blog')); ?>
    		<span class="pk_image_button_back_ground"></span>
    		<span class="pk_image_button_icon"></span>
    	</div>
    	<img src="<?php echo PK_THEME_DIR; ?>/parkerandkent2011/images/theme/image_icons/images_shadow.png" class="pk_image_shadow" alt="" />
    </div>
    <?php endif; ?>

    Some of it is styling. I have no idea how you should write it, but I guess they go around the function.. You'll have to play around with it. I can't help you any further, I'm sorry.. I don't know as much about php coding as I'd like..

  5. drumhead2u
    Member
    Posted 1 year ago #

    I am creating a real estate site and need help making this plugin work with the theme. I need to embed a vimeo video at the top where the featured image would go, but still have the featured image show up as the thumbnail on the front page. Looking through the forum has been a little overwhelming. I hope someone can get me going in the right direction.

    I do realize my situation may be a little bit different than previously discussed since the theme I am using has custom post types for properties like 'sale' and 'rent'.

    Any help is appreciated!

    I am using the theme deCorum.

    My test site is here:

  6. rjay3087
    Member
    Posted 1 year ago #

    How about showing the box for featured image in custom post???

    SOlve

  7. sbaroulette
    Member
    Posted 1 year ago #

    Hi. Still can't get my featured video box to appear in my posts after applying the fixes. It does show on my pages. Here's my single.php. Any help greatly appreciated.

    <?php
    /**
     * @package WordPress
     * @subpackage Default_Theme
     */
    
    ?>
    <?php include('headerblogdetail.php'); ?>
    
    <!-- Start Content -->
    <div id="content">
    	<!-- Start Main Content -->
    	<div id="main-content" class="move40">
    	<?php  if (have_posts()) : ?>
    
    		<?php while (have_posts()) : the_post(); ?>
    
             <img src="<?php bloginfo('template_directory'); ?>/images/aboutus_title.png" alt="" width="73" height="62" class="img-left wp-post-image" /> 
    
    		<div id="post">
    		  <h1><?php the_title(); ?></h1>
    
    		<h4><?php echo get_post_meta($post->ID, 'tagline', true) ?></h4>
            <div class="clear"></div>
    
    				<?php
    
    /************Here's the old code**********
    if ( has_post_thumbnail() ) {
    	?> <?php the_post_thumbnail('thumbnailblog2', array('class' => 'img-left')); ?>  <?php
    } else {
    	// the current post lacks a thumbnail
    }
    */
    /************Here's the new code**********/
    if(get_post_meta(get_the_ID(), "_related-video", true) != ''){
       // show the video embed code if there is one
        echo get_post_meta(get_the_ID(), "_related-video", true);
    }else{
           if (  (function_exists('has_post_thumbnail')) && (has_post_thumbnail())  ) {
        // show the image thumb if there is one, and the post does not have a video
        the_post_thumbnail('thumbnailblog2', array('class' => 'img-left'));
       }
    }
    ?>
    
    		<?php the_content(); ?>
    
    			<div class="main-ruler"></div>
    
    			<div id="author-bio" class="highlight-box">
    			<div class="img-box-small fl">
    			<?php echo get_avatar( get_the_author_email(), '112' ); ?>
    			</div>
    				<h3><?php echo get_the_author(); ?> </h3>
    				<p><?php the_author_meta('description'); ?></p>
    			</div>
    
    			<?php comments_template(); ?>
    		</div>	
    
    			<?php endwhile; ?>
    
    	<?php endif; ?>
    
    	</div>
    	<!-- End Main Content -->
    	<!-- Start Sidebar -->
    
    <?php include('sidebarblog.php'); ?>
    
    	<!-- End Sidebar -->
    	<div class="clear"></div>
    </div>
    <!-- End Content -->
    
    <?php get_footer(); ?>
  8. suus_artist
    Member
    Posted 1 year ago #

    I would really like to use this app also for my posts. I succeeded in placing the box on the page, but like many here I have problems with the second part.
    I have a single.php, but I can't seem to find out what part of it is about the featured image.
    Can anyone tell me what part of my single.php i need to replace?
    It now looks like this:

    <?php get_header(); ?>
    	<?php $shortname = "typographic"; ?>
    
    	<section id="single_cont">
    
    		<?php if (have_posts()) : while (have_posts()) : the_post(); ?>          
    
    			<h1 class="single_title"><?php the_title(); ?></h1>
    			<div class="single_inside_content">
    
    			<?php the_content(); ?>
    
    			</div><!--//single_inside_content-->
    			<br /><br />
    
    			<?php comments_template(); ?>
    
    		<?php endwhile; else: ?>
    			<h3>Sorry, no posts matched your criteria.</h3>
    		<?php endif; ?>                    		
    
    	</section><!--//single_cont-->
    
    	<section class="single_rand_cont">
    
    		<?php
    		$args = array(
    			 'post_type' => 'post',
    			 'posts_per_page' => 4,
    			 'orderby' => 'rand'
    			 );
    		query_posts($args);
    		$x = 0;
    		while (have_posts()) : the_post(); ?> 		
    
    			<?php if($x == 3) { ?>
    			<div class="home_post_box home_post_box_last">
    			<?php } else { ?>
    			<div class="home_post_box">
    			<?php } ?>
    
    				<a href="<?php the_permalink(); ?>"><?php the_post_thumbnail('home-post-box'); ?></a>
    				<div class="home_post_title"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></div>
    			</div><!--//home_post_box-->		
    
    		<?php endwhile; ?>
    		<?php wp_reset_query(); ?>
    
    	</section><!--//single_rand_cont-->
    
    	<div class="clear"></div>
    
    <?php get_footer(); ?>

    p.s. If anyone knows how to make a featured image without link, this would be very helpful for me also.
    Thx!!!

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic