Wordpress and Webdesign Forum go41 » WordPress Code Snippets

  1. Hi Joern,

    Hope all's well with you and yours. You helped me set up my adverts to run on different pages a while ago using conditional tags. That's been great but I've recently added OIO publisher onto the site and now I'm trying to work out how to format the code to include those.

    The idea is to sell individual pages to different companies, rather than adding all advertisers to all pages. So for example - this page here

    http://www.iamstaggered.com/wedding-speeches would have a sidebar advert from this company http://www.burnthetoast.com (they're already a sponsor so they're actually on most pages at the moment).

    That's all well and good but how do I actually input that into my current header and sidebar.php? For example the sidebar code currently looks like this

    <div id="sidebar">

    <div id="sidebar-ads">

    <?php if ( is_page('Favourbrook') ) { ?>
    <img src="<?php echo get_option('home'); ?>/wp-content/themes/arthemia/images/banners/testadvertsidebar.png" alt="" width="300px" height="250px" />
    <?php } elseif ( is_category('randallmurrow') ) { ?>
    <img src="<?php echo get_option('home'); ?>/wp-content/themes/arthemia/images/banners/Randallad.jpg" alt="" width="300px" height="250px" />
    <?php } elseif ( is_category('tobyluper') ) { ?>
    <img src="<?php echo get_option('home'); ?>/wp-content/themes/arthemia/images/banners/hemingwayadvert.jpg" alt="" width="300px" height="250px" />
    <?php } elseif ( is_page('stag-do-company-the-stag-company') ) { ?>
    <img src="<?php echo get_option('home'); ?>/wp-content/themes/arthemia/images/banners/stag-temporary-sidebar.jpg" alt="" width="300px" height="250px" />
    <?php } elseif ( is_page('stag-do-company-designaventure') ) { ?>
    <img src="<?php echo get_option('home'); ?>/wp-content/themes/arthemia/images/banners/DESIGNAVENTURE_SIDEBAR_1.jpg" alt="" width="300px" height="250px" />
    <?php } elseif ( is_page('style') ) { ?>
    <img src="<?php echo get_option('home'); ?>/wp-content/themes/arthemia/images/banners/swaggerandswoonsidebar1.jpg" alt="" width="300px" height="250px" />
    <?php } elseif ( is_page('wedding-accessories') ) { ?>
    <img src="<?php echo get_option('home'); ?>/wp-content/themes/arthemia/images/banners/swaggerandswoonsidebar1.jpg" alt="" width="300px" height="250px" />
    <?php } elseif ( is_single('wedding-ties-explained') ) { ?>
    <img src="<?php echo get_option('home'); ?>/wp-content/themes/arthemia/images/banners/swaggerandswoonsidebar1.jpg" alt="" width="300px" height="250px" />
    <?php } elseif ( in_category('1640') ) { ?>
    <img src="<?php echo get_option('home'); ?>/wp-content/themes/arthemia/images/banners/tiernansidebar.jpg" alt="" width="300px" height="250px" />
    <?php } else { ?>
    <img src="<?php echo get_option('home'); ?>/wp-content/themes/arthemia/images/banners/bttsidebarad1.jpg" alt="Speeches for weddings" width="300px" height="250px" />

    <?php } ?>
    </div>

    That being the case where would I put this - where would I add this code:

    <?php if(function_exists('oiopub_banner_zone')) oiopub_banner_zone(1, 'center'); ?>

    And how would I specify it to say that this belongs ONLY on the wedding speeches page?

    Any help would be fantastic.

    Posted 1 year ago #
  2. checking on OIO publisher I guess they would like the plugin code oiopub_banner_zone.. to be loaded with all pages and posts.
    You create the zones for Text Ads | Banner Ads | Inline Ads | Posts etc and insert the code it gives for each zone into the place you want.

    Advertiser can select in advertisers view which kind of add in which place they want to purchase.

    'And how would I specify it to say that this belongs ONLY on the wedding speeches page?'
    This might be the problem...
    Let's say you put the code for oiopub_banner_zone(1.. in a conditional tag only for the wedding speeches page, ie "if ( is_page('wedding-speeches')", the plugin will show only here the purchased adds.
    No idea how to tell this to the advertiser.

    regardless of this you can set up new zones, ie oiopub_banner_zone(2.. and put these in the conditional tag for other pages or categories.
    This zones you can give a title like: wedding speeches sidebar for zone1
    wedding accessories sidebar for zone2 etc

    If you got the plugin, you could try it out by putting it additionally to an existing page like
    banner zone1 to wedding-accessories
    banner zone2 to wedding-ties-explained

    for each zone you create you will get a new line of code in the plugins admin panel.

    code inside the else statement will show only if none of the conditions above are true.
    code just after <div id="sidebar-ads"> before any condition will show always.

    Posted 1 year ago #
  3. Brill, my question though is how would I phrase that in code? Does this look like it would break!?

    <?php
    if(function_exists('oiopub_banner_zone')) {
    $zone_id = 1;
    $options = array( 'subid' => $page_id 'wedding-speeches');
    $zone_id = 2;
    $options = array( 'subid' => $page_id 'best-man');
    $zone_id = 3;
    $options = array( 'subid' => $post_id '10beststagdos');
    oiopub_banner_zone($zone_id, $options);
    }
    ?>

    The admin on OIO says that it's possible to use sub-ids here http://forum.oiopublisher.com/discussion/1100/different-ads-on-each-page-ie-buddypresswpmu/

    Thanks Joern.

    Posted 1 year ago #
  4. this might be a way outside your 'conditions', not shure if $page_id 'best-man' works as they talk about $blog_id..

    I would create different zones, as explained above and put them in your existing conditions.
    As sample:

    <?php if ( is_page('Favourbrook') ) { ?>
    <?php if(function_exists('oiopub_banner_zone')) oiopub_banner_zone(1, 'center'); // THE CODE YOU GET ROM THE PLUGIN FOR EACH ZONE ?>
    <?php } elseif ( is_category('randallmurrow') ) { ?>
    <?php if(function_exists('oiopub_banner_zone')) oiopub_banner_zone(2, 'center'); ?>
    <?php } elseif ( is_category('tobyluper') ) { ?>
    ...

    to try it out,
    in plugin admin set the default code for your randallmurrow category banner the weddings.randallmurrow.com code you have now in the sidebar

    long sentence, hope you get what I mean?

    Posted 1 year ago #
  5. I asked the admin and this is what he said:

    ___________

    Project Admin

    With that particular technique, as long as the subID you specify is unique, you can put whatever you like there - so yes, you could use conditionals to create your own code, like:

    if author page, use a{author_id}, if category page, use c{category_id}, if page, use p{page_id}

    That's just an example, but hopefully it gives you the idea. It's a bit more involved than standard usage, but seemed to be the best way to give people control over specific pages / areas of the site.

    ___________

    Alternatively I guess I could just do as you've suggested and put the function_exists line in the conditional statement. I'm still a little hazy about how it would look but I could try!

    Posted 1 year ago #
  6. Wow Joern, I followed your advice and it works like a charm. All the code looks a lot neater now and the ad interface is a lot more professional, so a HUGE thank-you (as ever) to you.

    Posted 1 year ago #

RSS feed for this topic

Reply

You must log in to post.

Join us! or log in (lost password?):