SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Member
    Join Date
    Mar 2009
    Posts
    7
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Help with Alignment via PHP

    I am having trouble figuring out how to align the google adsense code via a PHP setting in my wordpress template to the left. It auto adjusts to the right.

    The website is at dailyfailblog . com and then click on any individual post for the problem (i dont have my 10 posts yet to put in an actual link)

    Here is the place where the ad is setup via code -

    PHP Code:
    <?php get_header(); ?>

    <div id="content">
    <div class="breadcrumb">
    <?php
    if (class_exists('breadcrumb_navigation_xt')) {
    // Display a prefix
    echo 'Navigation: ';
    // new breadcrumb object
    $mybreadcrumb = new breadcrumb_navigation_xt;
    // Display the breadcrumb
    $mybreadcrumb->display();
    }
    ?>
    </div>
    <?php if (have_posts()) : ?>

    <?php while (have_posts()) : the_post(); ?>
    <div class="single" id="post-<?php the_ID(); ?>">
    <div class="title">

    <h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a></h2>
    <div class="date"><span class="author">Posted by <?php the_author(); ?></span> <span class="clock"> On <?php the_time('F - j - Y'); ?></span></div>    
    </div>

    <div class="cover">
    <div class="entry">
                                <?php the_content('Read the rest of this entry &raquo;'); ?>

    <?php include (TEMPLATEPATH '/ad1.php'); ?>
                
                     <div class="clear"></div>
                
    </div>

    </div>

    <div class="singleinfo">
                        <div class="category"><?php the_category(', '); ?> </div>
                    
    </div>


    </div>
    <div class="related">
    <?php wp_related_posts(); ?>
    </div>
    <div class="clear"> </div>
    <div class="allcomments"> 
    <?php comments_template(); ?>
    </div>
        <?php endwhile; else: ?>

            <h1 class="title">Not Found</h1>
            <p>I'm Sorry,  you are looking for something that is not here. Try a different search.</p>

    <?php endif; ?>

    </div>


    <?php get_sidebar(); ?>
    <?php get_footer
    (); ?>
    The ad portion of the code is this <?php include (TEMPLATEPATH . '/ad1.php'); ?> in the above php.

    here is where that php code links to

    PHP Code:
    <div class="ad1">

    <?php $ad2 get_option('scar_ad2'); echo stripslashes($ad2); ?>

    </div>
    I'm a complete novice with coding at this point so bare with me please if what I'm asking doesn't make any sense. I will try to explain as much as possible if needed.

  2. #2
    SitePoint Guru silver trophy JamesColin's Avatar
    Join Date
    May 2009
    Location
    Jomtien, Pattaya, Thailand
    Posts
    910
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    the best is to put the ad BEFORE the content

    and you put a div around the ad code

    in the div you put float:right (or left) it looks like this:
    Code:
    <div style="float:right">ADSENSE CODE</div> CONTENT TEXT
    Do you really need traffic? Where to? What for?
    If you really do need traffic then stop messing around!
    Advertise on my sites today: She Told Me & Best Reviewer :
    200,000+ UV / Month

  3. #3
    SitePoint Member
    Join Date
    Mar 2009
    Posts
    7
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks a lot and yeah I know it is better monetization-wise to put the ad before the content, but I'm not in it for the money at this point. Just something to give my readers to click on if an ad fancies them. If I make $10 a month and pay for my cheap hosting, I'll be doing just fine in my opinion. Just a hobby I guess lol.

  4. #4
    SitePoint Guru silver trophy JamesColin's Avatar
    Join Date
    May 2009
    Location
    Jomtien, Pattaya, Thailand
    Posts
    910
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    No, I didn't meant to put it before the content for display (although yes that's what I think) but if you want the text to wrap around the ad, then the ad code has to be before the text and have that float:right or float:left.

    I'm just saying that if you put the ad code after the text, it will not work (I thought you wanted the text to wrap around the ad, sorry if I'm mistaken)
    Do you really need traffic? Where to? What for?
    If you really do need traffic then stop messing around!
    Advertise on my sites today: She Told Me & Best Reviewer :
    200,000+ UV / Month

  5. #5
    SitePoint Member
    Join Date
    Mar 2009
    Posts
    7
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Not a problem. I am sorry for not being clear. I just wanted the ad the justify to the left like everything else in the post. It used to justify to the right, but your idea worked just fine!


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •