WordPress.org

Ready to get started?Download WordPress

Forums

adding html code to body of page (8 posts)

  1. flatnote
    Member
    Posted 3 years ago #

    I am trying to ad an html script for an embedded video into the body of the home page. I only want the video to play on the home page. I've tried several plugins and and can't seem to get the video to play. The other embedded code works on the sidebar by using the text/html widget.

    I am using the thememagic theme, below is the script:

    [Code moderated as per the Forum Rules. Please use the pastebin]

  2. Samuel B
    moderator
    Posted 3 years ago #

    where are you inserting this code?
    In the theme's index.php or...?

  3. flatnote
    Member
    Posted 3 years ago #

    I am inserting the code into the page I created on the website not the index.php....Should I be adding the code to index.php.....?

  4. Samuel B
    moderator
    Posted 3 years ago #

    I would think so as that is what assembles/displays front page normally

  5. flatnote
    Member
    Posted 3 years ago #

    I tried inserting it into the index.php but it still didn't work.

    any other ideas..?

  6. Digital Raindrops
    Member
    Posted 3 years ago #

    Here's an UNTESTED idea, in 'WordPress 3' we have template parts.

    Create a new file called video-1.php in the themes folder and in the file add this code, and the script between the start and end lines.

    <?php
    /*
    * Added code below to return the video
    */
    ?>
    
    <?php if ( is_home() || is_front_page() ) : ?>
       <!-- Start add Script Here -->
    
       <!-- End add Script Here -->
    <?php endif ?>

    Then in the index.php or the home template page add

    <?php /* Insert the video here */ ?>
    <?php get_template_Part('video', 1 ); ?>

    Note: this is written from memory so test in a local install or make sure you have ftp so you can remove the file if you have to!

    See if this works?

    HTH

    David

  7. flatnote
    Member
    Posted 3 years ago #

    David - Thank You so much, your a life saver.....it worked.

  8. Digital Raindrops
    Member
    Posted 3 years ago #

    No problem,
    Great feature the <?php get_template_part( 'filename' ) ?> for injecting code blocks nice and clean, I use them all the time now!

    Mark this one resolved please.

    David

Topic Closed

This topic has been closed to new replies.

About this Topic