Support » Themes and Templates » How to add advertisement after first post?

  • Resolved bboy131

    (@bboy131)


    I have been trying to figure this out forever now. I have found a lot of sites that say “Hey just insert this code into your index.php file” but the problem is Mystique does not have the code they say is suppose to be there.

    I want to insert an Adsense block after the first post on homepage/pages.

    The code they gave me was

    <?php if(!$show_ads){ ?>

    [advertisement goes here]

    <?php $show_ads = 1; } ?>

    But that doesn’t work. Any ideas?

Viewing 15 replies - 1 through 15 (of 18 total)
  • Michael

    (@alchymyth)

    so, what does not work?

    where did you insert this code?

    and did you replace [advertisement goes here] with your adsense code?

    this code snippet with your own adsense code in the middle should be inserted into index.php before the line with <?php endwhile; ?>

    digitalnature

    (@digitalnature)

    go to mystique settings > advanced and in the ‘functions’ field add:

    <?php
    
    function my_ad_plugin(){
     if(is_home()){
       if(!$show_ads){
        ?>  [advertisement goes here] <?php
        $show_ads = 1;
       }
     }
    ]
    
    add_action('mystique_after_post', 'my_ad_plugin');
    ?>

    but I wouldn’t use plugins for this if I were you. mystique already has ad management features trough shortcodes…

    Thread Starter bboy131

    (@bboy131)

    @alchymtyh the ad does not show at all. My index.php file does not have a <?php endwhile; ?> in it or anything about posts. My page.php does and that file affects the homepage. So I cannot insert the code on index.php

    @digitalnature I added the code you provided and it highlights the last part in red and gives me an error when I load my website

    I don’t understand why this isn’t working. Should be simple lol

    digitalnature

    (@digitalnature)

    there’s a mistake above, replace ] with }.

    here’s another way, without any plugin:

    <?php
    function my_ads(){
      global $ads_already_displayed;
      if(is_home())
       if(!$ads_already_displayed){
        $ads_already_displayed = 1;
        echo do_shortcode('[ad code=2]');
       }
    }
    
    add_action('mystique_after_post', 'my_ads');
    ?>

    to set up the ad go to the ads tab and paste your adsense code or whatever in #2

    Michael

    (@alchymyth)

    Thread Starter bboy131

    (@bboy131)

    Alright I added the php code you provided into the Advanced section. Sometimes Adsense takes a while to show new ads, so I will let you know if it worked. Thanks for the help

    Thread Starter bboy131

    (@bboy131)

    It still doesn’t show up…GAH! It makes no sense. I have tried everything. Makes me feel like a WP newb even though I have been using it for a long time

    digitalnature

    (@digitalnature)

    replace the adsense from ad code #2 with some dummy text and see if it shows up.

    Thread Starter bboy131

    (@bboy131)

    Replaced with text and still not showing that. Hmmm

    digitalnature

    (@digitalnature)

    are you using mystique 2+ ?

    Thread Starter bboy131

    (@bboy131)

    No unfortunately I had some problems with trying to upgrade to the newest theme. When I upgraded to the newest, I had some CSS issues, so I kept version 1.72.

    I want to upgrade to the newest but I’m afraid of screwing up all of my editing on this template so I am just leaving it at the current 1.72 version.

    Thread Starter bboy131

    (@bboy131)

    This problem isn’t a huge deal. I can just live without it I guess.

    Thread Starter bboy131

    (@bboy131)

    To upgrade to the newest version, do I just remove the old theme folder and upload the new one? So I will have to redo the changes I want in the new theme.

    digitalnature

    (@digitalnature)

    yes.

    I would advise you not to make changes to the theme files in the future. The ‘functions’ and ‘user css’ options should be enough to make any modifications you want to the theme, without loosing them in updates

    Thread Starter bboy131

    (@bboy131)

    This theme is awesome but it seems to hate me lol.
    I upgraded to the newest 2.2 theme and now my sidebar titles are messed up.
    I put the link so you can see, the widgets are missing the header block backgrounds. I’ve removed and added widgets again but no go.

    http://img98.imageshack.us/img98/5721/mystique.png

    Sorry for all the bugging

Viewing 15 replies - 1 through 15 (of 18 total)
  • The topic ‘How to add advertisement after first post?’ is closed to new replies.