February 4, 201016 yr Hey , I have a Wordpress based website which I love! However, I would like to try and put Adsense on there to see what happens! I have a 120 x 240 box set up that I would like to put on my page. Could someone please let me know how I can put this as a sidebar located on the right of my page? I have the javascript for it and would like it to appear throughout the site. I presume I need to create a div box (or another .php?) into which I can paste my code into My link Thank you Leon
February 4, 201016 yr There's two ways you can do this: one is that you can paste the javascript into a text widget in your admin dashboard. This will then appear on your sidebar. Or you can paste the code into your sidebar.php file which is located in wp-content/themes/<your theme here>/ It should be pretty simple to figure out.
February 4, 201016 yr Author There's two ways you can do this: one is that you can paste the javascript into a text widget in your admin dashboard. This will then appear on your sidebar. Or you can paste the code into your sidebar.php file which is located in wp-content/themes/<your theme here>/ It should be pretty simple to figure out. Hi notbanksy, Thanks for the advice, would that put the ads in the left sidebar? Also I dont think my theme is widget ready Leon
February 4, 201016 yr You link is incorrect. You're missing the second B in http://businessbird.co.uk/. Whether your theme is widget ready or not, you should locate the file earlier described by notbanksy, called sidebar.php. This file should be inside your /wp-content/themes/wiki/ folder. Open it in your favorite editor and depending on where you'd like to position the AdSense box, paste in your code. Once you've got that, save the file, and see the result.
February 4, 201016 yr Author Sorry about that! I have pasted in into my sidebar .php file but the ads are all wrong! Any idea on how I can relocate the box to the top right? Thanks for the advice Leon My sidebar.php <?php global $user_ID, $user_identity, $user_level ?> <div id="sidebar"> <?php // Menu for subpages of current page // Only shows if the current page has subpages if($post->post_parent) { $parent = wp_list_pages("title_li=&include=".$post->post_parent."&echo=0"); $children = wp_list_pages("title_li=&child_of=".$post->post_parent."&echo=0"); } else { $parent = wp_list_pages("title_li=&include=".$post->ID."&echo=0"); $children = wp_list_pages("title_li=&child_of=".$post->ID."&echo=0"); } if ($children) { echo '<h3 class="pages">Sub Pages</h3>'; echo '<ul class="navigation">'; echo $parent; echo $children; echo '</ul>'; } // End Subpage menu ?> <?php // Category Navigation ?> <h3 class="folder">Skill Topics</h3> <ul id="navigation"> <?php wp_list_categories('depth=2&title_li='); ?> </ul> </center> <?php if (is_single() && function_exists('related_posts_by_category')) { $home = get_bloginfo("home"); echo '<h3 class="related">Related Articles</h3>'; echo '<div id="related">'; echo '<ul>'; related_posts_by_category( array( 'orderby' => 'post_date', 'order' => 'DESC', 'limit' => 5, 'echo' => true, 'before' => '<li>', 'inside' => '', 'outside' => '', 'after' => '</li>', 'rel' => 'nofollow', 'type' => 'post', 'message' => '<li><a href="'.$home.'">Sorry, no matches.</a></li>' ) ); echo '</ul>'; echo '</div>'; }?> <h3 class="search">Live Search</h3> <div id="livesearch"> <div class="ajax-loading"></div> <form method="get" action="<?php bloginfo('home'); ?>" autocomplete="off"> <fieldset> <input type="text" value="" name="s" id="s" class="text" style="margin-bottom: 10px;" /> </fieldset> </form> </div> <center> <a href="http://uk.linkedin.com/in/businessbird" > <img src="http://www.linkedin.com/img/webpromo/btn_myprofile_160x33.gif" width="160" height="33" border="0" alt="View business bird's profile on LinkedIn"> </a> <p style="padding-top:1.4em;"> <script src="http://widgets.twimg.com/j/2/widget.js"></script> <script src="http://widgets.twimg.com/j/2/widget.js"></script> <script> new TWTR.Widget({ version: 2, type: 'profile', rpp: 4, interval: 6000, width: '210', height: 300, theme: { shell: { background: '#3b5898', color: '#ffffff' }, tweets: { background: '#eceff4', color: '#000000', links: '#4aed05' } }, features: { scrollbar: false, loop: false, live: false, hashtags: true, timestamp: true, avatars: false, behavior: 'all' } }).render().setUser('businessbirduk').start(); </script> <p style="padding-top:1.4em;"> <center><script type="text/javascript" src="http://static.ak.connect.facebook.com/js/api_lib/v0.4/FeatureLoader.js.php/en_US"></script><script type="text/javascript">FB.init("ea2f2d13ce4708b543759c175a655d51");</script><fb:fan profile_id="273557128000" stream="0" connections="10" logobar="1" width="210"></fb:fan></fb:fan></center> <?php wp_list_bookmarks('depth=2&title_li='); ?> <p style="padding-top:1.4em;"> <?php // User Login Form ?> <?php if ( $user_ID ) { ?> <h3 class="unlocked">Control panel</h3> <ul class="users"> <li><p>Your currently signed in as:<br /> <strong><?php echo $user_identity ?></strong>.</p></li> <li><?php echo get_avatar( $user_ID, $size = '50' ); ?> <ul> <li><a href="<?php bloginfo('url') ?>/wp-admin/">Dashboard</a></li> <?php if ( $user_level >= 1 ) : ?> <li><a href="<?php bloginfo('url') ?>/wp-admin/post-new.php">Write an article</a></li> <?php endif // $user_level >= 1 ?> <?php if ( function_exists('wpWikiFAQsList')) { // The FAQs plugin is installed echo '<li><a href="'.get_bloginfo('wpurl').'/wp-admin/?page='.WPWIKIFAQS_FOLDER.'/addnew.php">Write a FAQ</a></li>'; } ?> <li><a href="<?php bloginfo('url') ?>/wp-admin/profile.php">Your Profile</a></li> <li><?php wp_loginout(); ?></li> </ul> </li> </ul> <?php } else { // If not logged in ?> <h3 class="locked">Sign In</h3> <ul class="users"> <li> <form action="<?php bloginfo('url') ?>/wp-login.php" method="post"> <fieldset> <label for="log">User <input type="text" name="log" id="log" value="<?php echo wp_specialchars(stripslashes($user_login), 1) ?>" size="22" class="text" /></label> <label for="pwd">Password <input type="password" name="pwd" id="pwd" size="22" class="text" /></label> <p> <label for="rememberme"><input name="rememberme" id="rememberme" type="checkbox" value="forever" class="checkbox" /> Remember me</label> <input type="hidden" name="redirect_to" value="<?php echo $_SERVER['REQUEST_URI']; ?>"/> <input type="submit" name="submit" value="Send" class="button" /> </p> </fieldset> </form> </li> <?php if ( get_option('users_can_register') ) { // If registration is open ?> <li><a href="<?php bloginfo('url') ?>/wp-register.php">Become a Memeber</a></li> <?php } // Close registration code ?> <li><a href="<?php bloginfo('url') ?>/wp-login.php?action=lostpassword">Recover password</a></li> </ul> <?php } // End User Login ?> <center><?php wp_widget_colorful_tag_cloud(array());?></center> <p style="padding-top:1.4em;"> <a href="javascript:void(0);" onclick="window.open('http://www.supergreenhosting.com/ecertified?domain='+document.domain+'','SuperGreenHosting','toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=570,height=680,left=300,top=200');"><img style="border:0px;" src="http://jdimg.com/supergreen/greenbadges/badge4.gif" alt="Green Web Hosting" /></a> <script type="text/javascript"><!-- google_ad_client = "pub-5915254124102989"; /* 120x240, created 2/4/10 */ google_ad_slot = "7010345918"; google_ad_width = 120; google_ad_height = 240; //--> </script> <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script> </center></div>
February 4, 201016 yr Author On a side note I am amazed how effective the selective targeting function is with Adsense- pretty clever!
February 4, 201016 yr Hehe, easy! Paste this instead: <?php global $user_ID, $user_identity, $user_level ?> <div id="sidebar"> <script type="text/javascript"><!-- google_ad_client = "pub-5915254124102989"; /* 120x240, created 2/4/10 */ google_ad_slot = "7010345918"; google_ad_width = 120; google_ad_height = 240; //--> </script> <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script> <?php // Menu for subpages of current page // Only shows if the current page has subpages if($post->post_parent) { $parent = wp_list_pages("title_li=&include=".$post->post_parent."&echo=0"); $children = wp_list_pages("title_li=&child_of=".$post->post_parent."&echo=0"); } else { $parent = wp_list_pages("title_li=&include=".$post->ID."&echo=0"); $children = wp_list_pages("title_li=&child_of=".$post->ID."&echo=0"); } if ($children) { echo '<h3 class="pages">Sub Pages</h3>'; echo '<ul class="navigation">'; echo $parent; echo $children; echo '</ul>'; } // End Subpage menu ?> <?php // Category Navigation ?> <h3 class="folder">Skill Topics</h3> <ul id="navigation"> <?php wp_list_categories('depth=2&title_li='); ?> </ul> </center> <?php if (is_single() && function_exists('related_posts_by_category')) { $home = get_bloginfo("home"); echo '<h3 class="related">Related Articles</h3>'; echo '<div id="related">'; echo '<ul>'; related_posts_by_category( array( 'orderby' => 'post_date', 'order' => 'DESC', 'limit' => 5, 'echo' => true, 'before' => '<li>', 'inside' => '', 'outside' => '', 'after' => '</li>', 'rel' => 'nofollow', 'type' => 'post', 'message' => '<li><a href="'.$home.'">Sorry, no matches.</a></li>' ) ); echo '</ul>'; echo '</div>'; }?> <h3 class="search">Live Search</h3> <div id="livesearch"> <div class="ajax-loading"></div> <form method="get" action="<?php bloginfo('home'); ?>" autocomplete="off"> <fieldset> <input type="text" value="" name="s" id="s" class="text" style="margin-bottom: 10px;" /> </fieldset> </form> </div> <center> <a href="http://uk.linkedin.com/in/businessbird" > <img src="http://www.linkedin.com/img/webpromo/btn_myprofile_160x33.gif" width="160" height="33" border="0" alt="View business bird's profile on LinkedIn"> </a> <p style="padding-top:1.4em;"> <script src="http://widgets.twimg.com/j/2/widget.js"></script> <script src="http://widgets.twimg.com/j/2/widget.js"></script> <script> new TWTR.Widget({ version: 2, type: 'profile', rpp: 4, interval: 6000, width: '210', height: 300, theme: { shell: { background: '#3b5898', color: '#ffffff' }, tweets: { background: '#eceff4', color: '#000000', links: '#4aed05' } }, features: { scrollbar: false, loop: false, live: false, hashtags: true, timestamp: true, avatars: false, behavior: 'all' } }).render().setUser('businessbirduk').start(); </script> <p style="padding-top:1.4em;"> <center><script type="text/javascript" src="http://static.ak.connect.facebook.com/js/api_lib/v0.4/FeatureLoader.js.php/en_US"></script><script type="text/javascript">FB.init("ea2f2d13ce4708b543759c175a655d51");</script><fb:fan profile_id="273557128000" stream="0" connections="10" logobar="1" width="210"></fb:fan></fb:fan></center> <?php wp_list_bookmarks('depth=2&title_li='); ?> <p style="padding-top:1.4em;"> <?php // User Login Form ?> <?php if ( $user_ID ) { ?> <h3 class="unlocked">Control panel</h3> <ul class="users"> <li><p>Your currently signed in as:<br /> <strong><?php echo $user_identity ?></strong>.</p></li> <li><?php echo get_avatar( $user_ID, $size = '50' ); ?> <ul> <li><a href="<?php bloginfo('url') ?>/wp-admin/">Dashboard</a></li> <?php if ( $user_level >= 1 ) : ?> <li><a href="<?php bloginfo('url') ?>/wp-admin/post-new.php">Write an article</a></li> <?php endif // $user_level >= 1 ?> <?php if ( function_exists('wpWikiFAQsList')) { // The FAQs plugin is installed echo '<li><a href="'.get_bloginfo('wpurl').'/wp-admin/?page='.WPWIKIFAQS_FOLDER.'/addnew.php">Write a FAQ</a></li>'; } ?> <li><a href="<?php bloginfo('url') ?>/wp-admin/profile.php">Your Profile</a></li> <li><?php wp_loginout(); ?></li> </ul> </li> </ul> <?php } else { // If not logged in ?> <h3 class="locked">Sign In</h3> <ul class="users"> <li> <form action="<?php bloginfo('url') ?>/wp-login.php" method="post"> <fieldset> <label for="log">User <input type="text" name="log" id="log" value="<?php echo wp_specialchars(stripslashes($user_login), 1) ?>" size="22" class="text" /></label> <label for="pwd">Password <input type="password" name="pwd" id="pwd" size="22" class="text" /></label> <p> <label for="rememberme"><input name="rememberme" id="rememberme" type="checkbox" value="forever" class="checkbox" /> Remember me</label> <input type="hidden" name="redirect_to" value="<?php echo $_SERVER['REQUEST_URI']; ?>"/> <input type="submit" name="submit" value="Send" class="button" /> </p> </fieldset> </form> </li> <?php if ( get_option('users_can_register') ) { // If registration is open ?> <li><a href="<?php bloginfo('url') ?>/wp-register.php">Become a Memeber</a></li> <?php } // Close registration code ?> <li><a href="<?php bloginfo('url') ?>/wp-login.php?action=lostpassword">Recover password</a></li> </ul> <?php } // End User Login ?> <center><?php wp_widget_colorful_tag_cloud(array());?></center> <p style="padding-top:1.4em;"> <a href="javascript:void(0);" onclick="window.open('http://www.supergreenhosting.com/ecertified?domain='+document.domain+'','SuperGreenHosting','toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=570,height=680,left=300,top=200');"><img style="border:0px;" src="http://jdimg.com/supergreen/greenbadges/badge4.gif" alt="Green Web Hosting" /></a> </center></div> Let me know if it doesn't work. I didn't much focus into it.
February 4, 201016 yr Author Hey empek OK my hosting is crap and things are not loading now (is this normal?), I will give it a go tomorrow! I'm trying to get the vertical skyscraper ad box to appear on the right of the screen ( parallel with the 'Skill topics' box but on the other side). This will kinda 'sandwich' the content! Hope all is good in the Big Apple Leon
February 4, 201016 yr Yea, try it tomorrow. I can't really give you advice on the skyscraper bit because your page is no loading up. ... things are not loading now (is this normal?) ... Yep, then instant you start replacing a file, the file will become unavailable, until new file is completely uploaded. Since your connection is slow, your upload might have timed out before completing the upload, and therefore hangs on an incomplete file, hence not serving up the page. I hope that makes sense! Try it tomorrow, and let me know how it goes. The Big Apple says hello!
February 5, 201016 yr Author Just checking out your site- love it, a really refreshing design! I have pasted your super .php code into my sidebar and it put the evil Google Adsense box at the top left. I've stuck a quick picture I whipped up in paint to this post as an idea of what I am after Thanks! Leon
February 5, 201016 yr Ooooooohhhhhhhhhh It's a little more work then before, but it's very possible. By the way, right now, none of your pages are even showing the main content. What you wanna do is, is structure your content like this, in all your pages Sidebar Content Rightbar Your code might look like this: ... <div id="page"> <?php get_sidebar(); ?> <div id="content"><!-- OR WHATEVER THE ID OF CONTENT IS --> <!-- PAGE CONTENT --> </div> <div id="rightbar"> <!-- ADSENSE CODE --> </div> </div><!-- end #page --> ... Now with that change you have to edit your CSS to where the width of #content is small enough for the adsense to fit in the #page element. sidebar + content + righbar <= page ( <= is less than or equal to ) Let me know if you need any more help. You can also hire me to do this for you. PS: Thanks for your comments!
Create an account or sign in to comment