Disabling/disallowing Adsense in a few places
-
Hi,
I just need some help: I want to use google adsense on my blog. But the fact, the the ads show after each post synopis when going to the category view is a pain. Is there an easy way to disable graphene ads only in the archives/categories/tags view of my website?
Somekind of custom css/html codes?
Admin
You would need to use a child theme to achieve this. Are you currently using one?
Nope, I don’t even know about such a thing, to be honest ^^”’
Admin
@ Yeti it is very easy, you can download the child theme from here:
http://www.prasannasp.net/graphene-child-theme-template/
Hi Syahir Hakim
I have a child theme.
I experience the same thing.
e.g. http://minmadopskrift.dk/category/dip-dressing, I want to remove the ads here, and on all other categories
Please inform how to remove ads with a child theme.
Thanks in advance
Oliver
Admin
Add this to your child theme’s
functions.php
file:/**
* Disable ads in certain places
*/
function my_disable_ads(){
global $graphene_settings;
if ( is_category() ) {
$graphene_settings['show_adsense'] = false;
}
}
add_action( 'template_redirect', 'my_disable_ads' );Make sure you wrap the code above in PHP’s opening
<?php
and closing?>
tags.I am sorry asking again. Here is my child php file. I try to insert the code in several places, but get an error message from w3 total cache, that Minify URL rewriting is not working. I can still see adsense.
What am I doing wrong? Where would you place the code?
<?php
// put your code here
function graphene_filter_gettext( $translated, $original, $domain ) {
$strings = array(
'Powered by %1$s and the %2$s.' => 'Min Madopskrift, min madopskrift på nettet',
);
if ( ! empty( $strings[$original] ) ) {
$translations = &get_translations_for_domain( $domain );
$translated = $translations->translate( $strings[$original] );
}
return $translated;
}
add_filter( 'gettext', 'graphene_filter_gettext', 10, 3 );
?>@Oliver, try this,
<?php
// put your code here
function graphene_filter_gettext( $translated, $original, $domain ) {
$strings = array(
'Powered by %1$s and the %2$s.' => 'Min Madopskrift, min madopskrift på nettet',
);
if ( ! empty( $strings[$original] ) ) {
$translations = &get_translations_for_domain( $domain );
$translated = $translations->translate( $strings[$original] );
}
return $translated;
}
add_filter( 'gettext', 'graphene_filter_gettext', 10, 3 );
/**
* Disable ads in certain places
*/
function my_disable_ads(){
global $graphene_settings;
if ( is_category() ) {
$graphene_settings['show_adsense'] = false;
}
}
add_action( 'template_redirect', 'my_disable_ads' );It is better if you create a separate thread for your issue. It becomes difficult to respond to OP’s question if somebody hijacks the thread.
Put code in between backtick (
Code:`) characters here in the forum. It’s usually located above the Tab key on your keyboard.
Viewing 10 posts - 1 through 10 (of 12 total)
- 1
- 2
- You must be logged in to reply to this topic.