- This topic is empty.
-
AuthorPosts
-
December 11, 2011 at 10:16 am #35589KortschotMember
Hi there…
My php knowledge is fairly limited. I can read it, I understand it but typing it is another game for me.
The thing i’m trying to accomplish is fairly simple for anyone with basic 1 on 1 PHP skills… hence the frustration why i’m not getting the result I was hoping for. Maybe because it’s a sunday… little wine. Anyway lets sketch my thing here…Im making a WP theme. With custom fields and some PHP I did the following:
– if there is a custom field named youtube with a value,
– inject the video
– else inject the featured imagewith the code:
if (get_post_meta($post->ID, "youtube", true))
// otherwise do nothing or post the featured image
else { ?>
?>
This is working like a charm, for the PHP masters here this probably can be accomplished much better or easier, but hey… I have to give myself some credit right =) A least it is posting the youtube video if the custom field is populated in the backend and if not it gets the featured image.
Now I want to add Vimeo. So it has to do the exact same thing. So the accomplishment here is:
– check for custom field youtube, if there… post it, otherwise post featured image
– check for custom field vimeo, if there… post it, otherwise post featured imageCan anybody kick me in the right direction? I probably get this to work with allot of excessive code… like to have a much cleaner function and code. and I know my PHP skills are just not good enough to be confident the code is clean.
Eventualy I want to add the JW-Player to get content from my own RTMP Server, but that’s the next step, and I think ill manage that if I get this part working.
Much obliged to anyone who wants to give this some thoughts.
With regards, Paul
December 11, 2011 at 10:39 am #92453SenffParticipant<< - check for custom field youtube, if there... post it, otherwise post featured image
– check for custom field vimeo, if there… post it, otherwise post featured image >>Not sure if this is actually what you want. I would think you meant this?
– check for custom field youtube, if there… post it, otherwise:
– check for custom field vimeo, if there… post it, otherwise:
– post featured imageWith this structure, you will only get a YouTube video, OR a Vimeo one, OR a featured image (in that order), never two or more of those.
ID, "youtube", true)) { ?>
// code for posting YouTube goes here
ID, "vimeo", true)) { ?>
// code for posting Vimeo goes here
// code for featured image goes here
Just doing it from the top of my head so may not be 100% correct syntax but give it a try and see if that does the trick….?
December 11, 2011 at 10:47 am #92454KortschotMemberHi Senff,
Thanks for your reply to this post. I think this is exactly what I needed.
The content that will be published will be in a “featured” place on the site. So either a YT or a Vimeo movie or just a featured image.Thanks a bunch. I will try tonight or tomorrow.
December 11, 2011 at 1:51 pm #92458KortschotMemberawesome! worked like a charm!
Now when I want to add an additional player, like the JW-player I just make another elseif statement right?
At least I’m there for 90% now, when I can’t figure out this next step i’ll ask a programmer at work… (I tend to like it when I figure stuff out for myself as a simple css monkey and flabbergast the programmers)
Thanks again m8, big help.
-
AuthorPosts
- The forum ‘Back End’ is closed to new topics and replies.