Import youtube vids, use JWplayer in theme only when metabox in admin is filled
by Jeroen
Home › Forums › JW Player 7 for WordPress › Import youtube vids, use JWplayer in theme only when metabox in admin is filled
- This topic has 5 replies, 2 voices, and was last updated 6 years, 8 months ago by
Jeroen.
-
AuthorPosts
-
7 January 2017 at 15:56 #1910
Jeroen
ParticipantHi,
I purchased your plugin and i works great! Now i have a question and want to know if my idead is possible.
I use Flex Mag theme for my site, i import youtube videos with Video Blogster. What i’d like to do is as follow:
I want to show Youtube videos in a post in JW Player only when the video url field of your plugin in admin (where you create the post) is filled, otherwise the featured image must be show. I know this can be done with if/elseif.
In Video blogster i can import the video url in a custom field, i think that had to be ‘_jwppp-video-url-1’.
I want to use the shortcode to display the video in stead of the featured image, i can manage that in my theme, that’s no problem.
I see that you can use this shortcode [jw7-video p=”67026″] (video of post 67026 will be shown). What code i have to use in my template file to get the (youtube) video of a post?
Earlier i used Featured Video plugin, the code taht i used to show the video (only when it has a video) was something like this in the thme file:
<?php if ( ( has_post_video() ) ) { ?>
<?php echo (the_post_video()); ?>and this coe in the function file was something like this:
<?php }
}if ( has_post_video() ) {
the_post_video();
{ ?>How can i create the function that tells wordpress to show the video when the metabox in admin is filled? And what will be the code for my theme file so i can only show the youtube video when the metabox in admin is filled?
so it has to be something like:
If …._jwppp-video-url-1
<?php echo do_shortcode([jw7-video p=”postid”]); ?>
elseif
If i know the function en theme code i think i can manage the rest myself. Hope you can help me in the right direction.
Thanks in advanced.
jeroen
9 January 2017 at 16:21 #1914ilGhera
KeymasterHi @jeroen, thanks for using my product.
_jwppp-video-url-1 is a post meta, the key of the post meta used for storing the first video url of a post/ page.
If you want to check if that field was filled, you can do it in this way:
Hope this helps 😉
9 January 2017 at 19:22 #1920Jeroen
ParticipantHi ilGhera,
Thanks, when i use the code below it works (it doens’t show the featured image, which is correct because the ‘_jwpp-vifeo-url-1’ is filled). Now i can’t get the shortcode to work.
<?php if (get_post_meta(get_the_ID(), ‘_jwppp-video-url-1’, true)) { ?>
How can i get the Post id IN the shortcode so the correct video is shown? I’ve tried the code below but it doesn’t show the player:
<?php echo do_shortcode(‘[jw7-video p=”. get_the_ID() .”]’); ?>
I think above code is not correct, can you tll me how to get the post id in the shortcode?
When i use the shortcode ([jw7-video p=”67127″]) in the content of the post the player is shown.
You can see a example here (it’s the post i’m testing on right now): https://edmfacts.com/releases/armin-van-buuren-garibay-need-feat-olaf-blackwood/
Hope you can help me further.
Kind regards,
Jeroen
-
This reply was modified 6 years, 8 months ago by
Jeroen.
9 January 2017 at 20:36 #1925Jeroen
ParticipantSorry the php code is no show correct when i post it on the forum here. So i make a image of it.
(image tag in this forum seems like not working also, can i send info in another way?)
My question is how to get the post id of the current post in the shortcode between p=”POST_ID”. i Think (hope) it will work then.
Hope it’s clear now, i you want to have any further information or site/FTP access please let me know.
Thanks,
Jeroen
-
This reply was modified 6 years, 8 months ago by
Jeroen.
10 January 2017 at 9:32 #1928ilGhera
KeymasterHi @Jeroen.
You can use this email address: info@ilghera.com
Anyway, the code I posted works inside the loop; the condition if checks if the current post… get_the_ID … has a specific post_meta or not.
If yes, the shortcode of the plugin is executed by the function echo do_shortcode();, that requires the shortcode itself as argument.
In your case, since you have to get the first video of the post/ page, you can simply use jw7-video, inside square brackets of course.10 January 2017 at 18:52 #1937Jeroen
ParticipantHi ilGerha,
Thanks for the info, it’s working. Thanks again for the great support and tips.
Will recommend your plugin to others for sure!
Kind regards,
Jeroen
-
This reply was modified 6 years, 8 months ago by
-
AuthorPosts
- You must be logged in to reply to this topic.