Support » Themes and Templates » adding html code to body of page

  • 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]

Viewing 7 replies - 1 through 7 (of 7 total)
  • where are you inserting this code?
    In the theme’s index.php or…?

    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…..?

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

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

    any other ideas..?

    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.

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



    David – Thank You so much, your a life saver… worked.

    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.


Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘adding html code to body of page’ is closed to new replies.