Add Adsense to the final Content Post

Community Forums Forums Design Tips and Tricks Add Adsense to the final Content Post

This topic is: not resolved

Tagged: 

This topic contains 9 replies, has 2 voices, and was last updated by  braddalton 1 year, 4 months ago.

Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #35909

    Manuel
    Participant
    Post count: 8

    Hi,

     

    I now is very simple but i can´t find the  correct code, I  want to add adsense  to the final of my post  but I add some pluggins and bars  and I need to add it before one bar (sharethis pluggin), also I need it to add it in the content area,

     

    I already try this code:

    add_action('genesis_after_post_content', 'adsense_after_posts');
    function adsense_after_posts() {
    if (is_single() )
        echo '<div class="adsense-style">Adsense goes here</div>';
    }  

    Thanks

    http://
    #35910

    braddalton
    Participant
    Post count: 9210

    Can you link to your site please.


    Specializing In StudioPress Child Theme Customization.
    500+ StudioPress Tutorials

    #35974

    Manuel
    Participant
    Post count: 8

    Hi. Brad:

    Here is the link

     

    http://comodefinirabdominales.com/como-reducir-grasa-en-el-abdomen-sin-abandonar-la-rutina/

    I want to add it before the share bar.

     

    Thanks!

    #35976

    Manuel
    Participant
    Post count: 8

    Also I need to add a Adsense banner before the shareThis pluggin but in the home page.

     

    http://comodefinirabdominales.com/

     

    Thanks!

    #36025

    Manuel
    Participant
    Post count: 8

    sorry, Also If you can help me with another issue, i need to add Adsense banner before the shareThis pluggin but in the home page, I get a little confused when I try to add the adsense.

    Here is the link of my website:

     

    http://comodefinirabdominales.com/

     

    Thanks

    Best Rewards!!

    #36028

    braddalton
    Participant
    Post count: 9210

    Try this:

    https://gist.github.com/5408822.git


    Specializing In StudioPress Child Theme Customization.
    500+ StudioPress Tutorials

    #36094

    Manuel
    Participant
    Post count: 8

    Thanks Brad it work great.

    I don’t want to bother, but i get a little frustrated,   I tried  this  code, it works, but if the   post have photos or another element like a video it will avoid those elemnts, and the banner will be in another part

    <code>

    add_filter( ‘the_content’, ‘wpsites_adsense_middle_content’ );
    function wpsites_adsense_middle_content( $content ) {
    if( !is_single() )
    return $content;

    $paragraphAfter = count ( $content ); //Enter paragraph number
    $content = explode ( “</p>”, $content );
    $new_content = ”;
    for ( $i = 0; $i <= count ( $content ); $i ++ ) {
    if ( $i == $paragraphAfter ) {
    $new_content .= ‘<div style=”width: 300px; height: 250px; padding: -5px -5px 0px 0; margin-right: 0;align=Top;display:inline-table;border:none;position:relative;float:left”>’;
    $new_content .= ‘<script type=”text/javascript”>Script Adsense</script>’;
    $new_content .= ‘<center><strong>Enlace Patrocinado</strong></center></div>’;
    }
    $new_content .= $content[$i] . “</p>”;
    }
    return $new_content;
    }

    </code>

    Also i now that always  in the content I  have  the <p></p> tag element,  the last  <p> is the ShareThis pluggin, I want to add it before the last <p> tag,I know i can count the elements of a class, but I cant implemented, What could be the best for to count the elements tags in a class, or is a function of theme than give me that info?

    http://comodefinirabdominales.com/como-reducir-grasa-en-el-abdomen-sin-abandonar-la-rutina/

     

    #36099

    braddalton
    Participant
    Post count: 9210

    Thats my code also. Where did you get it?

    You can’t use that code for what you want because its developed to display the Adense after a specific amount of paragraphs which will be different on different posts.

    You’ll find Adsense converts better when its above the fold and typically before the content which is where you might want to display your Adsense.

    I see you already add an image after posts so you have to change the hook or add a thrid parameter for the priority.

    What code are you using for displaying the image after single posts?


    Specializing In StudioPress Child Theme Customization.
    500+ StudioPress Tutorials

    #36203

    Manuel
    Participant
    Post count: 8

    I get it here , in the forum, you posted this code in another thread,I read past  posts to try to solve this problem,, I use this code:

    <code>

    add_filter( ‘the_content’, ‘wpsites_adsense_middle_content’ );
    function wpsites_adsense_middle_content( $content ) {
    if( !is_single() )
    return $content;

    $paragraphAfter = 0; //Enter paragraph number
    $content = explode ( “</p>”, $content );
    $new_content = ”;
    for ( $i = 0; $i < count ( $content ); $i ++ ) {
    if ( $i == $paragraphAfter ) {
    $new_content .= ‘<div style=”width: 300px; height: 250px; padding: -5px -5px 0px 0; margin-right: 0;align=Top;display:inline-table;border:none;position:relative;float:left”>’;
    $new_content .= ‘Adsense Code’
    $new_content .= ‘<center><strong>Enlace Patrocinado</strong></center></div>’;
    }
    $new_content .= $content[$i] . “</p>”;
    }
    return $new_content;
    }

    </code>

    I aslo  tied usging wp insert, but  I cant get   the position exactly where i want it, I  want to Add a 300×250 banner between the image and the  sharethis Bar, that the reason i want to add it always before the  last<p> tag.

     

    Thanks !!

     

    #36255

    braddalton
    Participant
    Post count: 9210

    O.k I Understand where you want it displayed but don’t know which hook you are currently using for the after post image.

    I think you should try and add another widget area before the image which looks like its using the same hook.

    Which hook is it using Manual?

    Or you could use another hook or add a priority to another function using the same hook or use 2 text widgets in the same widget area.


    Specializing In StudioPress Child Theme Customization.
    500+ StudioPress Tutorials

Viewing 10 posts - 1 through 10 (of 10 total)

You must be logged in to reply to this topic.