Block Adsense on specific page

You can use this function: <?php if(is_page(‘your-page-slug’)): ?> //do nothing on selected pages <?php else: ?> <script async src=”https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js” /> <script> </script> <?php endif; ?> If you want to disable this on more than one page, just add them like this: <?php if(is_page(‘your-page-slug1’) || is_page(‘your-page-slug2’)): ?> WordPress Developer Resources are very useful (more than codex), … Read more

Inserting AdSense code right after tag

Without using a plugin, the WordPress way would be to use the wp_head action to insert the script and then enqueue the script file: function mytextdomain_adsense() { $output=” <script> </script>”; echo $output; } add_action(‘wp_head’,’mytextdomain_adsense’); function mytextdomain_adense_script() { wp_enqueue_script( ‘my-adsense’, ‘//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js’, array(), ‘1.0.0’, false ); } add_action( ‘wp_enqueue_scripts’, ‘mytextdomain_adense_script’ ); And to add the async attribute … Read more

Adding Google Custom Search to a Public Released Theme

You can improve it, combining Google Search and WordPress Search. using this simple javascript: function displaygoogle(checkbox){ if(checkbox.checked){ document.getElementById(“googlesearchbox”).style.display = ‘block’; document.getElementById(“wordpresssearchbox”).style.display = ‘none’; document.getElementById(“googlesearchinput”).value = document.getElementById(“wordpresssearchinput”).value; } else{ document.getElementById(“googlesearchbox”).style.display = ‘none’; document.getElementById(“wordpresssearchbox”).style.display = ‘block’; document.getElementById(“wordpresssearchinput”).value = document.getElementById(“googlesearchinput”).value; } } see more detail here: http://jaider.net/2011-05-08/how-to-combine-google-wordpress-search/

Offering Ads Dependent on Visitor Type?

There are systems that do something similar, particularly for Example 2. What Would Seth Godin Do, for example, stores a cookie in the user’s browser that tracks the number of times they’ve visited the site. If they’re a new visitor (have visited less than 5 times), it displays a message suggesting they subscribe to the … Read more

Adding ads after a certain number of paragraphs within Genesis themework

I’ve found explode() to be useful when trying to break strings apart. This code creates an array of paragraph chunks, inserts the new block after two paragraphs and concatenates it back into a string for output. function insert_ad_block( $text ) { if ( is_single() ) : $ads_text=”<div class=”wpselect_middle_content”>My Ad Code Here</div>”; $split_by = “\n”; $insert_after … Read more

How do I show google ads between post content?

You can use a shortcode or the_content filter. I think the_content filter is better because your don’t introduce any string in your post, so the content can be exported and used in another platforms if needed. For emxample, for show a block of adsense after the first parragraph: add_filter( ‘the_content’, ‘tbn_ads_inside_content’ ); function tbn_ads_inside_content( $content … Read more

Inserting ads within content

Have faith 😉 Unfortunately, your code ain’t correct in multiple ways. It assumes that the content only consists of content enclosed by paragraphs and doesn’t work correctly if not. This would be one solution: add_filter(‘the_content’, ‘prefix_insert_post_ads’); /** * Content Filter */ function prefix_insert_post_ads($content) { $insertion = ‘Your AD Code’; if (is_single() && ! is_admin()) { … Read more