Wordpress and Webdesign Forum go41 » WordPress Code Snippets

  1. Hi Joern,

    I've got a vague feeling that you might have helped me with something similar before but I can't find the answer.

    Essentially, all I want to do is change a single page so that it has a different sidebar and header ad. e.g. http://www.iamstaggered.com/style/favourbrook would have a Favourbrook ad at sidebar and header.

    Please help me Joern, you're my only hope!

    Posted 1 year ago #
  2. Put a conditional tag around the different adds, like this:

    <?php if ( is_single('Favourbrook') ) { ?>
    do Favourbrook add here
    <?php } else { ?>
    do any other stuff here
    <?php } ?>

    that's just for this single post, more conditional tags see here:

    http://codex.wordpress.org/Conditional_Tags

    btw: is my 'Subscribe To Topic via Email' working in this forum?

    Posted 1 year ago #
  3. The forum's being weird!

    Posted 1 year ago #
  4. Let me try again as it seemed to take that post

    - thank-you
    - notification is working great
    - does the conditional code go in sidebar.php and header.php?

    Posted 1 year ago #
  5. I see your reply..
    now changed to weird..

    Posted 1 year ago #
  6. anywhere, in header.php make space under your add, paste the code as is and look if you see the text 'do Favourbrook add here' or 'do any other stuff here' under your head.
    If yes it's working and you put your different adds instead of the text.
    sidebar.php ditto

    while editing header.php you could delete:

    <meta name="generator" content="WordPress <?php bloginfo('version'); ?>" />

    as this comes twice in your source code, once generated by wordpress alone

    Posted 1 year ago #
  7. For some reason I don't think the forum likes me posting code...

    Posted 1 year ago #
  8. I'll try posting a very small section:

    <a href="<?php echo get_option('home'); ?>/"><img src="<?php echo get_option('home'); ?>/wp-content/themes/arthemia/images/logotrial3.jpg" width="410px" height="110px" alt="" /></a>
    	<div id="tagline"><?php bloginfo('description'); ?></div>
    	</div>
    
    	<div class="right">
    <?php if ( is_single('Favourbrook') ) { ?>
    <a href="http://www.iamstaggered.com" onClick="javascript: pageTracker._trackPageview('/outgoing/www.designaventure.co.uk');"><img src="<?php echo get_option('home'); ?>/wp-content/themes/arthemia/images/banners/testadvert.png" alt="" width="450px" height="130px"  /></a><?php } else { ?>
    <a href="http://www.designaventure.co.uk" onClick="javascript: pageTracker._trackPageview('/outgoing/www.designaventure.co.uk');"><img src="<?php echo get_option('home'); ?>/wp-content/themes/arthemia/images/banners/Designaventureadjan.jpg" alt="" width="450px" height="136px"  /></a>
    <?php } ?>
    	</div>

    Ok, that seems to do it - this is from header.php but it doesn't amend the Favourbrook page to use the testadvert.png - any ideas where I'm going wrong?

    Posted 1 year ago #
  9. it seems not to recognize the is_single
    you could try with the ID of this post is_single('17') 17 sould be your ID
    or with the page slug is_single('favourbrook')

    I hope we talk about a single post? that's not a page or category, right?

    If it's a page you need:

    is_page('favourbrook')

    Posted 1 year ago #
  10. JOERN/MASTERADMIN I BLOODY LOVE YOU. THAT IS ALL.

    Ahem, yes, it was a page, not a single post. Whoops.

    Posted 1 year ago #
  11. Hi Joern,

    More on this I'm afraid - I can't quite seem to format the tags for a series of conditional tags.

    What I want is different sidebar ads depending on the page (e.g. some will be different ads for blog categories, some for individual pages, etc).

    For that reason I think I need to create a set of conditions such as below, but using this gives me a parsing error. Any chance you could give me a pointer?

    Thanks again.

    Dr_Whom

    <div id="sidebar">
    
    <div id="sidebar-ads">
    <?php if ( is_page('Favourbrook') ) { ?>
    <a href="http://www.iamstaggered.com"><img src="<?php echo get_option('home'); ?>/wp-content/themes/arthemia/images/banners/testadvertsidebar.png" alt="" width="300px" height="250px"  /></a><?php } elseif <?php if ( is_category('randallmurrow') ) { ?>
    <a href="http://weddings.randallmurrow.com/"><img src="<?php echo get_option('home'); ?>/wp-content/themes/arthemia/images/banners/randallad.jpg" alt="" width="300px" height="250px"  /></a><?php } else { ?>
    <a href="http://www.iamstaggered.com/forum/challenge-staggered/how-does-it-work">
    <img src="<?php echo get_option('home'); ?>/wp-content/themes/arthemia/images/banners/Ateam11.png" alt="" width="300px" height="250px" />
    </a><?php } ?>
    
    </div>
    
    <div id="sidebar-top">
    <?php 	/* Widgetized sidebar, if you have the plugin installed. */ 					if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar(1) ) : ?>
    
    <?php endif; ?>
    </div>
    
    <div id="sidebar-middle" class="clearfloat">
    <div id="sidebar-left">
    <?php 	/* Widgetized sidebar, if you have the plugin installed. */ 					if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar(2) ) : ?>
    <?php endif; ?> 
    
    <ul><?php wp_list_bookmarks('categorize=0&category=17&title_li=0&show_images=0&show_description=0&orderby=name'); ?></ul>
    </div>  
    
    <div id="sidebar-right">
    <?php 	/* Widgetized sidebar, if you have the plugin installed. */ 					if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar(3) ) : ?> 		
    
    <h3>Blogroll</h3>
    
    <ul>
    <li><a href="http://colorlabsproject.com">Colorlabs Project</a></li>
    <li><a href="http://michaelhutagalung.com">Michael Jubel</a></li>
    <li><a href="http://www.hannasyalala.com">Hanna Siahaan</a></li>
    <li><a href="http://majarimagazine.com">Majari Magazine</a></li>
    <li><a href="http://bloggerzine.majarikanayakan.com">The Bloggerzine</a></li>
    <li><a href="http://www.majarikanayakan.com">Majari Kanayakan</a></li>
    </ul>
    <?php endif; ?>
    </div> 
    
    </div>
    
    <div id="sidebar-bottom">
    <?php 	/* Widgetized sidebar, if you have the plugin installed. */ 					if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar(4) ) : ?>
    <?php endif; ?> </div>   
    
    </div>
    Posted 1 year ago #
  12. you got a typing error "elseif <?php if"
    this should work:

    <?php if ( is_page('Favourbrook') ) { ?>
    <a href="http://www.iamstaggered.com" onClick="javascript: pageTracker._trackPageview('/outgoing/www.designaventure.co.uk');"><img src="<?php echo get_option('home'); ?>/wp-content/themes/arthemia/images/banners/testadvertsidebar.png" alt="" width="300px" height="250px"  /></a>
    <?php } elseif ( is_category('randallmurrow') ) { ?>
    <a href="http://weddings.randallmurrow.com/"><img src="<?php echo get_option('home'); ?>/wp-content/themes/arthemia/images/banners/randallad.jpg" alt="" width="300px" height="250px"  /></a>
    <?php } elseif ( is_category('anyothercat') ) { ?>
    anyothercat thing
    <?php } elseif ( is_tag('stag-do') ) { ?>
    thing for tag stag-do
    <?php } else { ?>
    <a href="http://www.iamstaggered.com/forum/challenge-staggered/how-does-it-work">
    <img src="<?php echo get_option('home'); ?>/wp-content/themes/arthemia/images/banners/Ateam11.png" alt="" width="300px" height="250px" />
    </a>
    <?php } ?>
    Posted 1 year ago #
  13. Brilliant - thank-you!

    Posted 1 year ago #
  14. You could also use a plugin like the Graceful Sidebar Plugin. This simple plugin enables you to customize your posts or pages with unique sidebar content.

    Enjoy!
    Mike

    Posted 7 months ago #

RSS feed for this topic

Reply

You must log in to post.

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