Community Forums › Forums › Archived Forums › Design Tips and Tricks › Need help with putting Adsense Ads above the post title and below the header…
Tagged: above post title, adsense, before entry title
- This topic has 7 replies, 2 voices, and was last updated 9 years ago by
naturalsoldier.
-
AuthorPosts
-
March 6, 2016 at 10:12 pm #180784
naturalsoldier
MemberHi,
I'm trying to insert Adsense Ads above the main content (above post title and below header)
on some of the main pages which include:Home Page
Category Pages
Single Post PagesAgain I only want this ad to show up once on each page (at the top below the
header and above the first post title), and I only want it to show up in
the main content column.Please see a screenshot of the site that I am modeling mine after and
notice the arrow pointing to the ad placement that I'm trying to
replicate....I think I have successfully accomplished this but need some feedback to
make sure it checks out or if there is a better way.Below is the code that I have used with the plugin "Simple Hooks" to make
this happen:(Note... I have placed this code in the genesis_before_entry hook)
<?php
global $wp_query;
if( ($wp_query->current_post == 0) && is_home() ) {
?>
<div class="codeblocktop">Sponsored Links
[My Adsense Code Here}
</div>
<?php
}
?><?php
if(is_single() ) {
?>
<div class="codeblocktop">Sponsored Links
[My Adsense Code Here}
</div>
<?php
}
?><?php
global $wp_query;
if( ($wp_query->current_post == 0) && is_archive() ) {
?>
<div class="codeblocktop">Sponsored Links
[My Adsense Code Here}
</div>
<?php
}
?>This code has accomplished what I wanted it to, but I have some concerns that I would really appreciate help with...
1.) Is the code correct and will it mess anything up?
2.) Is there a cleaner piece of code that will accomplish the same thing?
3.) Will my changes will get erased with updates?
4.) Is the code placed in the correct hook location (genesis_before_entry)?
5.) Is there a better way to accomplish what I'm trying to do?
Like I said... it's working exactly how I want it to but just want to double check with folks who actually know what they're doing and make sure that I didn't mess anything up!
Please forgive me as I am new to WordPress and learning as I go. I would
appreciate any help you can give me. Thanks!P.S. My Child Theme: eleven40
http://snag.gy/n7JtI.jpgMarch 7, 2016 at 8:40 am #180802Brad Dalton
ParticipantMarch 7, 2016 at 3:31 pm #180824naturalsoldier
MemberOops... sorry about that!
My site is at http://weluvdogs.com/
I would appreciate any help you can give.
Thanks!
March 7, 2016 at 8:04 pm #180864naturalsoldier
MemberIs there anybody in here that can help?
March 8, 2016 at 9:54 am #180910Brad Dalton
ParticipantI would use the
genesis_entry_header
hook or an earlier hook with the
is_singular('post'))
conditional tag And add a new widget area there.
March 8, 2016 at 3:19 pm #180939naturalsoldier
MemberThank you Brad. Can you please clarify what you mean in your response? Not sure I quite understand what you're saying to do. Sorry just new to all of this so want to make sure that I completely understand what you are saying here.
Also, is there a cleaner piece of code that I should use?
Thanks again!
March 8, 2016 at 5:17 pm #180955Brad Dalton
ParticipantMarch 9, 2016 at 12:58 am #180978naturalsoldier
MemberThank you Brad but I've read that tutorial and re-read it about 10 times and I still can't figure it out lol.
Here's what I've done so far...
I placed the following code to register the new widget in my eleven40 functions.php file (note jerod is my name and what I've used to make the name unique so I can recognize it easily):
//* Register jerod before post title widget area
genesis_register_sidebar( array(
'id' => 'jerod-before-post-title',
'name' => __( 'Jerod Before Post Title', 'eleven40' ),
'description' => __( 'This is a widget area that can be placed before the post title', 'eleven40' ),
) );The next part in the tutorial is where I get lost... How do I write the next part of the code in the tutorial and where do I place it? Sorry for being so dense on this... again learning as I go.
-
AuthorPosts
- The forum ‘Design Tips and Tricks’ is closed to new topics and replies.