Page With Scripting, Best Practice?

Community Forums Forums General Discussion Page With Scripting, Best Practice?

This topic is: resolved

This topic contains 8 replies, has 3 voices, and was last updated by  bionary 5 months ago.

Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #104568

    bionary
    Member
    Post count: 38

    I’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.

    #104573

    braddalton
    Participant
    Post count: 10182

    If 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.


    #104580

    bionary
    Member
    Post count: 38

    add 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 )
    Thanks

    #104595

    braddalton
    Participant
    Post count: 10182
    #104596

    braddalton
    Participant
    Post count: 10182
    #104646

    bionary
    Member
    Post count: 38

    I’m afraid it’s a local instance. I’m just getting the feel for wordpress and genesis locally before I dare port it live.

    #104852

    essaysnark
    Participant
    Post count: 342

    @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?

    #104853

    essaysnark
    Participant
    Post count: 342

    Also 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):

    http://www.carriedils.com/custom-page-template-genesis/

    #105667

    bionary
    Member
    Post count: 38

    ah, ok thanks.

Viewing 9 posts - 1 through 9 (of 9 total)

You must be logged in to reply to this topic.