WordPress.org

Ready to get started?Download WordPress

Forums

how to add a javascript advertisement (8 posts)

  1. sophie
    Member
    Posted 1 year ago #

    [ Moderator note: de-capped the title and removed "urgent". Please do not use all caps and this is not "urgent". ]

    Hi!

    I am using Twenty Ten 1.1 theme and I need to add a advertisement in JAVASCRIPT ABOVE my header image using the following code:

    [ Moderator Note: Please post code or markup snippets between backticks or use the code button. ]

    <script type='text/javascript'>
    var atwMN='93367328', atwWidth='728', atwHeight='90'
    </script>
    <script type='text/javascript'
    src="http://o.aolcdn.com/ads/adsWrapper3.js"></script<http://o.aolcdn.com/ads/adsWrapper3.js>>

    The website is: betterdecoratingbible (dot) com

    How would I do this and where would I put this coding in? In the header html? I also need it to be a centered banner.

    Please be VERY VERY specific as I'm not so HTML/JavaScript savvy.

    Thanks!

  2. WPyogi
    Volunteer Moderator
    Posted 1 year ago #

    You should never change theme files directly so making a child theme is the first step:
    child theme

    It looks like you've already changed the header.php file -- and you have code above the DOCTYPE -- which causes major problems. You need to remove that or at least put it below the DOCTYPE -- but in a child theme.

  3. sophie
    Member
    Posted 1 year ago #

    Thanks for your quick response! I have already attempted to make a Child Theme before and I haven't had any success since I have already made lotss of changes to my parent theme. If I keep a back up of all my .css and html code will I be safe then? I don't plan on updating wordpress so I don't think I will lose any of my changes.

    So do you think you could help me out with the Java Script above?

    Thanks!

  4. ronangelo
    Member
    Posted 1 year ago #

    Put your ad codes inside a div. Then put the whole thing just below the <body> tag.

    <div style="text-align: center;">
    Put codes here...
    </div>

    Anyway you should rethink about updating your WP and Themes. You wouldn't want your sites to get hacked.

  5. WPyogi
    Volunteer Moderator
    Posted 1 year ago #

    No, keeping a backup is not a solution and not updating is a very bad idea -- as ronangelo mentioned, some updates have to do with security issues, so it's crucial that you do those.

    If you have a copy of what you have changed, you should be able to make a child theme and move the changes there.

    You still have major errors in your header.php file:

    http://validator.w3.org/check?uri=http%3A%2F%2Fbetterdecoratingbible.com%2F&charset=%28detect+automatically%29&doctype=Inline&group=0

  6. sophie
    Member
    Posted 1 year ago #

    thanks for all the advice! can someone please point me to a tutorial where i can make a child theme after i have already made changes to the twenty ten theme?

    can i just copy all of my files from twenty ten and put them into the new child theme?

  7. sophie
    Member
    Posted 1 year ago #

    ronangelo - I do not have a body tag inside my header.php. this is my current header html, where would I insert the javascript for the ad so that it shows up above my header image?

    [large amount of code moderated - please review http://codex.wordpress.org/Forum_Welcome#Posting_Code and consider to use a pastebin - the removed code was corrupted by the forum's parser]

  8. sophie
    Member
    Posted 1 year ago #

    <?php
    /**
     * The Header for our theme.
     *
     * Displays all of the <head> section and everything up till <div id="main">
     *
     * @package WordPress
     * @subpackage Twenty_Ten
     * @since Twenty Ten 1.0
     */
    ?><!DOCTYPE html>
    
    <!-- Begin comScore Tag -->
    <script>
      var _comscore = _comscore || [];
      _comscore.push({ c1: "2", c2: "15716746" });
      (function() {
        var s = document.createElement("script"), el = document.getElementsByTagName("script")[0]; s.async = true;
        s.src = (document.location.protocol == "https:" ? "https://sb" : "http://b") + ".scorecardresearch.com/beacon.js";
        el.parentNode.insertBefore(s, el);
      })();
    </script>
    <noscript>
      <img src="http://b.scorecardresearch.com/p?c1=2&c2=15716746&cv=2.0&cj=1" />
    </noscript>
    <!-- End comScore Tag -->
    
    <html <?php language_attributes(); ?>>
    <head>
    
    <meta charset="<?php bloginfo( 'charset' ); ?>" />
    <title><?php
    	/*
    	 * Print the <title> tag based on what is being viewed.
    	 */
    	global $page, $paged;
    
    	wp_title( '|', true, 'right' );
    
    	// Add the blog name.
    	bloginfo( 'name' );
    
    	// Add the blog description for the home/front page.
    	$site_description = get_bloginfo( 'description', 'display' );
    	if ( $site_description && ( is_home() || is_front_page() ) )
    		echo " | $site_description";
    
    	// Add a page number if necessary:
    	if ( $paged >= 2 || $page >= 2 )
    		echo ' | ' . sprintf( __( 'Page %s', 'twentyten' ), max( $paged, $page ) );
    
    	?></title>
    <link rel="profile" href="http://gmpg.org/xfn/11" />
    <link rel="stylesheet" type="text/css" media="all" href="<?php bloginfo( 'stylesheet_url' ); ?>" />
    <link rel="pingback" href="<?php bloginfo( 'pingback_url' ); ?>" />
    <?php
    	/* We add some JavaScript to pages with the comment form
    	 * to support sites with threaded comments (when in use).
    	 */
    	if ( is_singular() && get_option( 'thread_comments' ) )
    		wp_enqueue_script( 'comment-reply' );
    
    	/* Always have wp_head() just before the closing </head>
    	 * tag of your theme, or you will break many plugins, which
    	 * generally use this hook to add elements to <head> such
    	 * as styles, scripts, and meta tags.
    	 */
    	wp_head();
    ?>
    
    <link rel="stylesheet" type="text/css" href="http://cache.blogads.com/965857969/feed.css" />
    </head>
    
    <body <?php body_class(); ?>>
    <div id="wrapper" class="hfeed">
    	<div id="header">
    		<div id="masthead">
    			<div id="branding" role="banner">
    				<?php $heading_tag = ( is_home() || is_front_page() ) ? 'h1' : 'div'; ?>
    				<<?php echo $heading_tag; ?> id="site-title">
    					<span>
    						<a href="<?php echo home_url( '/' ); ?>" title="<?php echo esc_attr( get_bloginfo( 'name', 'display' ) ); ?>" rel="home"><?php bloginfo( 'name' ); ?></a>
    					</span>
    				</<?php echo $heading_tag; ?>>
    				<div id="site-description"><?php bloginfo( 'description' ); ?></div>
    
    				<?php
    					// Check if this is a post or page, if it has a thumbnail, and if it's a big one
    					if ( is_singular() && current_theme_supports( 'post-thumbnails' ) &&
    							has_post_thumbnail( $post->ID ) &&
    							( /* $src, $width, $height */ $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'post-thumbnail' ) ) &&
    							$image[1] >= HEADER_IMAGE_WIDTH ) :
    						// Houston, we have a new header image!
    						echo get_the_post_thumbnail( $post->ID );
    					elseif ( get_header_image() ) : ?>
    						<img src="<?php header_image(); ?>" width="<?php echo HEADER_IMAGE_WIDTH; ?>" height="<?php echo HEADER_IMAGE_HEIGHT; ?>" alt="" />
    					<?php endif; ?>
    			</div><!-- #branding -->
    
    			<div id="access" role="navigation">
    			  <?php /*  Allow screen readers / text browsers to skip the navigation menu and get right to the good stuff */ ?>
    				<div class="skip-link screen-reader-text"><a href="#content" title="<?php esc_attr_e( 'Skip to content', 'twentyten' ); ?>"><?php _e( 'Skip to content', 'twentyten' ); ?></a></div>
    				<?php /* Our navigation menu.  If one isn't filled out, wp_nav_menu falls back to wp_page_menu.  The menu assiged to the primary position is the one used.  If none is assigned, the menu with the lowest ID is used.  */ ?>
    				<?php wp_nav_menu( array( 'container_class' => 'menu-header', 'theme_location' => 'primary' ) ); ?>
    			</div><!-- #access -->
    		</div><!-- #masthead -->
    		</div><!-- #header -->
    <br><br>
    <br>
    
    <div id="main">

Topic Closed

This topic has been closed to new replies.

About this Topic