Last active
September 19, 2020 16:01
-
-
Save rickrduncan/6184003 to your computer and use it in GitHub Desktop.
Add Google AdSense into WordPress category pages.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- STEP 2 --> | |
<!-- The code below is placed into a file named adsense-archive.php as noted in the Gist above. --> | |
<div id="archive-adsense-wrapper"> | |
<div class="ad-left"> | |
<script type="text/javascript"><!-- | |
google_ad_client = "ca-pub-xxxxxxxxxxxxx"; | |
google_ad_slot = "xxxxxxxxx"; | |
google_ad_width = 250; | |
google_ad_height = 250; | |
//--> | |
</script> | |
<script type="text/javascript" | |
src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> | |
</script> | |
</div> | |
<div class="ad-right"> | |
<script type="text/javascript"><!-- | |
google_ad_client = "ca-pub-xxxxxxxxxxxx"; | |
google_ad_slot = "xxxxxxxxxx"; | |
google_ad_width = 250; | |
google_ad_height = 250; | |
//--> | |
</script> | |
<script type="text/javascript" | |
src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> | |
</script> | |
</div> | |
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//* Do NOT include the opening php tag | |
/** | |
* STEP 1: This code is to be placed into functions.php | |
* Place Google AdSense code into archive pages | |
* | |
* @author Rick R. Duncan | |
* @link http://www.rickrduncan.com | |
* | |
*/ | |
//for HTML5 themes | |
//add_action('genesis_entry_header', 'b3m_include_google_ads', 9); | |
//for XHTML themes | |
//add_action('genesis_before_post_title', 'b3m_include_google_ads', 9); | |
function b3m_include_google_ads() { | |
global $loop_counter; | |
if ( is_archive() && $loop_counter == 2 ) | |
require_once(ABSPATH.'/lib/adsense-archive.php'); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment