Community Forums › Forums › Archived Forums › General Discussion › Page With Scripting, Best Practice?
- This topic has 8 replies, 3 voices, and was last updated 12 years, 3 months ago by
bionary.
-
AuthorPosts
-
May 11, 2014 at 6:37 pm #104568
bionary
MemberI've been a web developer for a long time but always custom coded everything. This is my first attempt at wordpress and I just bought the beautiful theme.
What is the best practice for handling custom scripting (php) on a single page? For example... where do i place scripts? Do I need to make a page template? If so how? When I look at the existing templates all I see is:
genesis();I'm trying to create a page like : http://mygroovysite/video/xyz123abc
What I'm trying to make happen is the page template "video" is loaded and then a youtube video with id "xyz123abc" plays.
I've done this numerous times before on my own custom sites so scripting is not the problem, it's understanding the best practices in the world of wordpress that I need help with.
I know somebody is going to post a link to some youtube plugin but to be honest I'm yet to see a plugin do precisely what I'd like it to.
May 11, 2014 at 6:58 pm #104573Brad Dalton
ParticipantIf you're referring to PHP, you have 2 choices.
1. Add the code directly to a template file
2. Add a conditional tag after the function in your child themes functions file.
May 11, 2014 at 7:41 pm #104580bionary
Memberadd this to my child theme? I'm using "beautiful".
will this break updates?1. when i open page.php template all i see is: genesis(); not sure how to add php here? wouldn't the scripts results get added after or before the page and not inside the page?
2. can you provide an example please? not sure what "the function" means.
(I'm brand new to wp )
ThanksMay 11, 2014 at 8:55 pm #104595Brad Dalton
ParticipantMay 11, 2014 at 8:55 pm #104596Brad Dalton
ParticipantMay 12, 2014 at 8:02 am #104646bionary
MemberI'm afraid it's a local instance. I'm just getting the feel for wordpress and genesis locally before I dare port it live.
May 12, 2014 at 10:47 pm #104852essaysnark
Participant@bionary, what is the behavior that you want, exactly?
In WordPress, you can just put the URL to a YouTube video directly in a post or page (using the text editor) and it'll load the player right there, with no iframe or special coding required. It won't start playing the video automatically when the page is loaded though. Is that what you are trying to do?
May 12, 2014 at 10:52 pm #104853essaysnark
ParticipantAlso to answer your original question: You can insert custom PHP code in any template file - before the genesis() function - here's a simple tutorial that shows how (which happens to load some videos too):
May 17, 2014 at 5:44 pm #105667bionary
Memberah, ok thanks.
-
AuthorPosts
- The forum ‘General Discussion’ is closed to new topics and replies.