Manually editing ads into wordpress themes?

by Banned 5 replies
6
Hello Warriors,
I have quite a few wordpress sites such as Tv Stands for LCD Tvs and I would like to place ads into the content itself.

I see some sites with ads in the content on the top left corner of the article and would really like to do this as well.

Can someone kindly let me know how to add adsense blocks into the top left corner of the content or in the bid paragraph?

Thanks very much in advance.

Best Regards,
Benjamin
#programming #ads #editing #manually #themes #wordpress
  • Hi Benjamin,

    Simple answer:
    You can insert the Adsense code manually or use one of several plugins.

    More info:
    My experience with this is ~1.5 years ago.
    If I was doing it today I would search for the latest updates of "Wordpress Adsense Plugins"
    • [ 1 ] Thanks
  • Depends on your theme. Go into Appearence->Editor and start searching for the right file...probably header.php

    This might take some time, but its doable.
  • Yes, definitely can be done via plugin or manually by copy and paste into the WP template files. Personally I prefer the manual method for better performance and less dependencies.
  • The easiest way would be to use a plugin, but if you just want to insert a simple ad box at the top of every post, you can do this:

    Appearance -> Editor -> Single.php (or index.php depending on how your theme is setup)

    Look for the start of the wordpress loop, which looks something like this:

    Code:
    while(have posts)...
    Right below that you should see something like this (varies depending on the theme):

    Code:
    <h1><?php the_title(); /></h1>
    <?php the_content(); ?>
    What you want to do is insert a simple div between those 2 lines that wraps around some kind of php include:

    Code:
    <h1><?php the_title(); /></h1>
    <div style="float: right; width: 300px;"><?php include('http://www.mysite.com/ad.php'); ?></div>
    <?php the_content(); ?>
    Then create ad.php on your site and put your ad code into it, i.e.:

    Code:
    <a href="#"><img src="whatever" /></a>
    Voila! Your blog now displays an ad at the top of every blog post, and you can just change ad.php to change what ad is shown across all pages.

Next Topics on Trending Feed