Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace featured image with video from posts? #5

Closed
daddiofaddio opened this issue Feb 8, 2022 · 5 comments
Closed

Replace featured image with video from posts? #5

daddiofaddio opened this issue Feb 8, 2022 · 5 comments
Labels
help wanted Extra attention is needed

Comments

@daddiofaddio
Copy link

First, thanks for this plugin...it's awesome! I am using the "sc-swiper-card.php" template to pull the posts into the carousel. I have a post category titled "youtube" which contains only youtube videos. Right now, the slider only displays the youtube thumbnail which does not link to or play the youtube video from the posts. I would like to pull both the youtube thumbnail and the actual embeded video from the youtube category posts and have it placed where the featured image normally is for the template as well as have it clickable/playable. Is there a way to modify the "featured image" portion of code in the template to do this?

@crftwrk
Copy link
Member

crftwrk commented Feb 9, 2022

Thank you!

You can do this with ACF https://wordpress.org/plugins/advanced-custom-fields/.

Check example here https://dev.bootscore.me/plugins/bs-swiper/.

  • Install plugin
  • Create a field group
  • Create a text field and name it youtube
  • Add <?php the_field('youtube'); ?> direct below <?php the_post_thumbnail('medium', array('class' => 'card-img-top')); ?> in sc-swiper-card.php in your child's copy:
<!-- Featured Image-->
<?php the_post_thumbnail('medium', array('class' => 'card-img-top')); ?>
<!-- Youtube -->
<?php the_field('youtube'); ?>
  • Copy Youtube embed code and paste it in post edit screen in the new youtube field (show video in the loop)
  • Copy Youtube video link and embed it with video block on the top of the page.

Insert featured image only in non-youtube category posts.

Does this help?

@crftwrk crftwrk added the help wanted Extra attention is needed label Feb 9, 2022
@daddiofaddio
Copy link
Author

Thanks for the quick response!

I added the ACF field and everything works great! The only problem I have is that I have multiple sliders on the same page showing different social media posts. For example, I have a slider for youtube posts and one for Twitter. If I comment out the code for the featured image, it works great for the youtube slider but also removes the featured image for the other sliders as well. Is there a way to add a section to the code saying something like "if the category is [some category] use ACF field only, not featured image"? Or maybe a way to have separate shortcodes for sliders with featured image and those with video? Sorry if that is asking too much and I understand if that is not possible. Thanks for your help!

@crftwrk
Copy link
Member

crftwrk commented Feb 11, 2022

Much more simpler.

Don‘t comment out the featured image code. Leave the featured image in youtube posts blank and add embed code to the ACF field. Then show in first block after heading your video again. Youtube category will show video in loop and post, just like a featured image.

For all other posts, don‘t insert something in the ACF field. Use featured image for them. So you can mix all categories.

Solved?

@daddiofaddio
Copy link
Author

Yes, much simpler...solved and works perfectly!

There aren't many (good) Bootstrap5/Wordpress integrations out there that truly adhere to Bootstrap standards. Your themes/plugins are by far the best. Thanks again.

@crftwrk
Copy link
Member

crftwrk commented Feb 11, 2022

You‘re welcome 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants