Video embeds in AlxPosts widget
-
I’ve been able to embed video into post thumbnails and the featured content slider using this thread: https://www.ads-software.com/support/topic/thumb-1?replies=2
Is it possible to do the same thing inside the AlxPosts widget – set it up to display a video category and pull these embeded videos for the thumbnails? Thanks.
-
Hi domesticgood. The code blocks in content.php and alx-posts.php are essentially the same so it would seem possible. You’d copy /functions/widgets/alx-posts.php to your child theme. This is the default block of code:
<?php if($instance['posts_thumb']) { // Thumbnails enabled? ?> <div class="post-item-thumbnail"> <a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"> <?php if ( has_post_thumbnail() ): ?> <?php the_post_thumbnail('thumb-medium'); ?> <?php elseif ( ot_get_option('placeholder') != 'off' ): ?> <img src="<?php echo get_template_directory_uri(); ?>/img/thumb-medium.png" alt="<?php the_title(); ?>" /> <?php endif; ?> <?php if ( has_post_format('video') && !is_sticky() ) echo'<span class="thumb-icon small"><i class="fa fa-play"></i></span>'; ?> <?php if ( has_post_format('audio') && !is_sticky() ) echo'<span class="thumb-icon small"><i class="fa fa-volume-up"></i></span>'; ?> <?php if ( is_sticky() ) echo'<span class="thumb-icon small"><i class="fa fa-star"></i></span>'; ?> </a> </div> <?php } ?>
Based on the info in the thread you linked I think you would modify it like this:
<?php if($instance['posts_thumb']) { // Thumbnails enabled? ?> <?php if ( has_post_format( 'video' ) ): ?> <?php get_template_part('inc/post-formats'); ?> <?php else : ?> <div class="post-item-thumbnail"> <a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"> <?php if ( has_post_thumbnail() ): ?> <?php the_post_thumbnail('thumb-medium'); ?> <?php elseif ( ot_get_option('placeholder') != 'off' ): ?> <img src="<?php echo get_template_directory_uri(); ?>/img/thumb-medium.png" alt="<?php the_title(); ?>" /> <?php endif; ?> <?php if ( has_post_format('video') && !is_sticky() ) echo'<span class="thumb-icon small"><i class="fa fa-play"></i></span>'; ?> <?php if ( has_post_format('audio') && !is_sticky() ) echo'<span class="thumb-icon small"><i class="fa fa-volume-up"></i></span>'; ?> <?php if ( is_sticky() ) echo'<span class="thumb-icon small"><i class="fa fa-star"></i></span>'; ?> </a> </div> <?php endif; ?> <?php } ?>
I haven’t actually tested this so no guarantees…;-)
bdbrown, thanks for the reply! I appreciate it.
I replaced the code as you suggested and saved /functions/widgets/alx-posts.php to my child theme. Unfortunately, still no video for the post thumbnails inside the alx-posts widget – just the filler graphic.
Any other thoughts?
Well, dang, I was hoping it would just work…;-) Can you give me an example of a post you have set up that works like you want it to in the blog page. Is the video code embedded in the editor? Or did you use the Video post format? If it’s a video post format, did you use the Video URL or the Video Embed Code option? Does it have an excerpt? Featured image? Thanks.
Here’s a video post that works on the home page and on the post page: https://blog.domesticgood.com/farming-in-the-fields-and-some-rachmaninoff/. I set it up using the Video post format using the video URL and no featured image.
BTW, I also notice -as in the alx-posts widget – that the stock photo is also used in the recommended section at the bottom of the post page. That would be something we would want to have updated as well.
OK, thanks for the link. I’ll worry about the other “recommended” section later. If I understand the request, it is to be able to play the videos where they are, in the sidebar, without actually opening the post?
Ha ha, sorry to cloud the issue. Thanks again for your help.
Actually, I don’t really care whether the videos play where they are – that was just what I stumbled upon as a possible solution. What I was originally trying for was a way to automatically pull a thumbnail for the video without going through setting the featured image.
I got it to work; screenprint here. I installed a fresh copy of Hueman from the author’s web site; new v2.2.0 released today. Made the same changes to content-standard.php, content-featured.php and alx-posts.php. The two content-x files are in the new version. I don’t know if upgrading to v2.2.0 will fix it on your site, but the customization does work.
That’s great that it works! I updated the theme as you recommended and checked alx-posts.php again. But no luck on my end.
Here’s what I have in alx-posts.php right now in that section (and the lines directly above and below it). Is it right? Did I post it in the right place:
<ul class="alx-posts group <?php if($instance['posts_thumb']) { echo 'thumbs-enabled'; } ?>"> <?php while ($posts->have_posts()): $posts->the_post(); ?> <li> <?php if($instance['posts_thumb']) { // Thumbnails enabled? ?> <?php if ( has_post_format( 'video' ) ): ?> <?php get_template_part('inc/post-formats'); ?> <?php else : ?> <div class="post-item-thumbnail"> <a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"> <?php if ( has_post_thumbnail() ): ?> <?php the_post_thumbnail('thumb-medium'); ?> <?php elseif ( ot_get_option('placeholder') != 'off' ): ?> <img src="<?php echo get_template_directory_uri(); ?>/img/thumb-medium.png" alt="<?php the_title(); ?>" /> <?php endif; ?> <?php if ( has_post_format('video') && !is_sticky() ) echo'<span class="thumb-icon small"><i class="fa fa-play"></i></span>'; ?> <?php if ( has_post_format('audio') && !is_sticky() ) echo'<span class="thumb-icon small"><i class="fa fa-volume-up"></i></span>'; ?> <?php if ( is_sticky() ) echo'<span class="thumb-icon small"><i class="fa fa-star"></i></span>'; ?> </a> </div> <?php endif; ?> <?php } ?> <div class="post-item-inner group">
Ugh. I’ve been doing this too long…;-) Copy this function to your child theme functions.php file. It loads the alx-posts.php from the child theme instead of the parent theme.
function alx_load() { // Load theme languages load_theme_textdomain( 'hueman', get_template_directory().'/languages' ); // Load theme options and meta boxes load_template( get_template_directory() . '/functions/theme-options.php' ); load_template( get_template_directory() . '/functions/meta-boxes.php' ); // Load custom widgets load_template( get_template_directory() . '/functions/widgets/alx-tabs.php' ); load_template( get_template_directory() . '/functions/widgets/alx-video.php' ); load_template( get_stylesheet_directory() . '/functions/widgets/alx-posts.php' ); // Load custom shortcodes load_template( get_template_directory() . '/functions/shortcodes.php' ); // Load dynamic styles load_template( get_template_directory() . '/functions/dynamic-styles.php' ); // Load TGM plugin activation load_template( get_template_directory() . '/functions/class-tgm-plugin-activation.php' ); }
Sorry about the go ’round and delay.
I added the code to child theme functions.php and got this error:
Parse error: syntax error, unexpected ‘&’ in /home/blogdo7/public_html/wp-content/themes/hueman-child-master 2/functions.php on line 7Anything else in your functions.php file?
Here’s what I have:
<?php
/* ————————————————————————- *
* Custom functions
/* ————————————————————————- */
function alx_load() {
// Load theme languages
load_theme_textdomain( 'hueman', get_template_directory().'/languages' );// Load theme options and meta boxes
load_template( get_template_directory() . '/functions/theme-options.php' );
load_template( get_template_directory() . '/functions/meta-boxes.php' );// Load custom widgets
load_template( get_template_directory() . '/functions/widgets/alx-tabs.php' );
load_template( get_template_directory() . '/functions/widgets/alx-video.php' );
load_template( get_stylesheet_directory() . '/functions/widgets/alx-posts.php' );// Load custom shortcodes
load_template( get_template_directory() . '/functions/shortcodes.php' );// Load dynamic styles
load_template( get_template_directory() . '/functions/dynamic-styles.php' );// Load TGM plugin activation
load_template( get_template_directory() . '/functions/class-tgm-plugin-activation.php' );
}Hmmm. I just now created a new functions.php file and copied your code in, and didn’t get any compile errors. When does that error pop up?
After I uploaded functions.php via FTP the error appears when I refresh the blog homepage.
- The topic ‘Video embeds in AlxPosts widget’ is closed to new replies.