How do I add ads to frontpage of wordpress?

8 replies
  • WEB DESIGN
  • |
Hi,

I've setup a wordpress blog, and added amazon ads in the different posts.

My frontpage shows excerpts from my posts, but I would also like to add some ads at the top and at the bottom of the page. For example an amazon widget.
I would also like to do this on the search pages/tag pages.

How do I do this?

Thanks.

Best regards,
Thomas
#add #ads #frontpage #wordpress
  • Profile picture of the author angelie
    How did you add the amazon ads in your posts? Is it via plugin? If you are familiar editing your wordpress theme, you can hardcode the ads in the following files:
    - home.php (front page)
    - search.php (search results page)
    - tag.php (tag template page)

    If any of the above files don't exist yet in your theme, in most cases, you can copy index.php and rename it into home.php (or search.php or tag.php)
    {{ DiscussionBoard.errors[4595155].message }}
  • Profile picture of the author ThomasTe
    Hi Angelie,

    I've simply used the Amazon html code that comes with one of it's widgets.
    I'm using the standard 20-11 design, but have no experience with php. Where should I add the code on these pages, if I want to show at the top of the page (below the menu bar, though), and at the bottom (above the footer)?

    Thanks.

    Best regards,
    Thomas
    {{ DiscussionBoard.errors[4595173].message }}
    • Profile picture of the author angelie
      Originally Posted by ThomasTe View Post

      Hi Angelie,

      I've simply used the Amazon html code that comes with one of it's widgets.
      I'm using the standard 20-11 design, but have no experience with php. Where should I add the code on these pages, if I want to show at the top of the page (below the menu bar, though), and at the bottom (above the footer)?

      Thanks.

      Best regards,
      Thomas
      The easiest way is to put the ads in header.php and footer.php so they will be shown in all pages - front page, search page, tags page, etc.

      To place it at the top of every page:
      1. Open header.php
      2. Scroll to the bottom and you'll find this line:
      Code:
      <div id="main">
      3. Below that line, add your ads html code. You may want to wrap your ads within a separate div like this:
      Code:
      <div id="main">
        <div>html code here</div>
      4. Save

      To place at the bottom of every page (above the footer / footer widgets):
      1. Open footer.php
      2. At the top of the file, you'll find this line:
      Code:
      </div><!-- #main -->
      3. Just before that line, add you ads html code:
      Code:
        <div>html code here</div>
      </div><!-- #main -->
      4. Save

      Then test, you may want to add some margin too between the ads and other elements.
      {{ DiscussionBoard.errors[4595630].message }}
  • Profile picture of the author Velant
    Originally Posted by ThomasTe View Post

    I would also like to add some ads at the top and at the bottom of the page. For example an amazon widget.
    I would also like to do this on the search pages/tag pages.

    How do I do this?

    Thanks.

    Best regards,
    Thomas
    this plugin will help you
    WordPress › Random / Rotating Ads V2 « WordPress Plugins
    {{ DiscussionBoard.errors[4595233].message }}
  • Profile picture of the author ThomasTe
    Thanks, guys - really useful! I'll look into that immediately.
    Is there a way to define that I want this ad on this page, that ad on that page, etc.?
    The reason is, so that the ads are targeted toward the specific content.

    Thanks.

    Best regards,
    Thomas
    {{ DiscussionBoard.errors[4611349].message }}
    • Profile picture of the author angelie
      I don't know of a plugin that can do that. But that can be achieved by using custom fields (i.e. Custom Field Template plugin). You can add the following custom fields:
      1. Top ads
      2. Bottom ads

      So you can enter different ads on page 1 and page 2 for example. Setting up the custom fields in the theme files requires some coding though. If you are familiar editing wordpress themes, I can give you specific instructions.
      {{ DiscussionBoard.errors[4612859].message }}
  • Profile picture of the author ThomasTe
    Thanks, angelie. Actually I used your tip below, but instead simply added my code to index.php. Works like a charm now.

    Thanks.

    Best regards,
    Thomas
    {{ DiscussionBoard.errors[4622073].message }}
  • Profile picture of the author ThomasTe
    Actually I think I might be using it together with the plugin Velant suggested.

    Again, thanks.

    Best regards,
    Thomas
    {{ DiscussionBoard.errors[4626367].message }}

Trending Topics