WordPress.org

Ready to get started?Download WordPress

Forums

Ads between posts (21 posts)

  1. groentjie
    Member
    Posted 2 years ago #

    I already have ads after 1st and 2nd article but now want differents ads after each posts on the frontpage. how can i do that?

  2. groentjie
    Member
    Posted 2 years ago #

    No one?

  3. SGHB
    Member
    Posted 2 years ago #

    Edit Main Index Template (index.php) and put the ad code after the Post Content

  4. alchymyth
    The Sweeper & Moderator
    Posted 2 years ago #

    please define how you want to achieve the 'different' part - do you have a pool of ads and want to grab one random ad?

    where are your ads coming from at the moment?

  5. groentjie
    Member
    Posted 2 years ago #

    Ads are coming from Google Admanager on this site doesburgdirect.nl
    Now you see a ad before and after the first post, but i want to put a code between every post (10 posts) for a different banner. so it will be:

    banner 1
    1st post
    banner 2
    2nd post
    banner 3
    3rd post
    banner 4
    4th post
    banner 5

    and so on

  6. alchymyth
    The Sweeper & Moderator
    Posted 2 years ago #

    I already have ads after 1st and 2nd article

    can you post the code?
    please use the http://pastebin.com/ for any code longer than 10 lines.

    do you have an influence which ads get shown?
    is there a limit of ads per page?

  7. groentjie
    Member
    Posted 2 years ago #

    Yes I can control the ads

    <iframe src="http://pastebin.com/embed_iframe.php?i=PGmKBEqa" style="border:none;width:100%"></iframe>

  8. alchymyth
    The Sweeper & Moderator
    Posted 2 years ago #

    you could use (theoritically - as I don't know the actual code of your template) the $wp_query->current_post variable, which starts with zero for the first post in the loop, and a conditional statement to assign different ads for each post position (possibly adding the post ad information into an array for easier access ?)

  9. groentjie
    Member
    Posted 2 years ago #

    That's a nice answer but i dont understand it I think.

  10. alchymyth
    The Sweeper & Moderator
    Posted 2 years ago #

    please start by pasting the existing code of your template - the code that you are using to show the ads - into a http://pastebin.com/ and post the link to it here.

  11. groentjie
    Member
    Posted 2 years ago #

  12. alchymyth
    The Sweeper & Moderator
    Posted 2 years ago #

    <?php if ($postnum == $showadsense1) {
    echo '
    <center><!-- begam{S3} --></center>
    ';
    } ?>

    is the rest done with a plugin?
    where is the $showadsense variable defined?
    is S3 connected to a particular ad?

  13. groentjie
    Member
    Posted 2 years ago #

    Yes I can make S3, A4 and so on
    yes with the google admanager plugin

  14. alchymyth
    The Sweeper & Moderator
    Posted 2 years ago #

    try to replace the sectiopn that I posted in my last reply, with:

    <?php
    if ($postnum == 1) {
    echo '<center><!-- begam{S3} --></center>';
    } elseif ($postnum == 2) {
    echo '<center><!-- begam{A4} --></center>';
    } elseif ($postnum == 3) {
    echo '<center><!-- begam{so on} --></center>';
    } ?>

    add as many 'elseif's as you need.

  15. groentjie
    Member
    Posted 2 years ago #

    Ok this is my code but its not good, can you help me please?

  16. alchymyth
    The Sweeper & Moderator
    Posted 2 years ago #

    but its not good

    please post alink to your site to illustrate what is or what is not working.

  17. groentjie
    Member
    Posted 2 years ago #

    site. This is the code code
    I can also give you access to the admin

  18. alchymyth
    The Sweeper & Moderator
    Posted 2 years ago #

    you need to move the code from lines 2 - 14 (watch for the corresponding php tags) to replace the code in lines 71 - 75;

    edited code in http://pastebin.com/chF7BmGb

  19. groentjie
    Member
    Posted 2 years ago #

    Works. great!!!

  20. groentjie
    Member
    Posted 2 years ago #

    Only strange thing is that after the second and after 3rd it does not show but after that it shows again.

  21. alchymyth
    The Sweeper & Moderator
    Posted 2 years ago #

    this might be caused by the ads you are trying to show - the code istself is working and there is some output where the logic would expect it; i.e. it is not a wordpress problem.

    for instance, you are using 'fullheader1' (which seems to be {S4} ) right at the beginning, and then later in the conditional section - that ad is then not shown betweent the posts;

    also, your counter starts with 0 (i.e. it is not set until it gets incremented once; but your conditionals start with 1; therefore there is no ad after the first post.

    make sure to have all different ads in the differnt locations; and possibly change the numbers in the conditional section, for instance start the section with if ($postnum == 0) {

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags