Amp Adsense reklami konu icine makale icine reklam nasil koyulur kendim denedim oldu kesin cozum 1 gunluk arastirmam sonunda yaptim cogu kisi bu bilgiyi ucretli olarak paylasiyor.
Not :Konu hakkında Yorum kesinlikle yapınız Anında destek verilir
WordPress sitenize ftp gerekmeden nasil nereye bu kodu koyacaginizi sizlere genis bir sekikde aciklayacagim.
Sizlere öncelikle öncelikle yaptığım şekilde ekran görüntüsü atayım iyice emin olun.
WordPress sitenize girin Gorunumler _ Duzenleyici
Sonra function.php dosyasına aşağıdaki kodu mutlaka eklemek gerekir. Bu kodu eklemediğiniz takdirde aşağıdaki reklam yerleşim kodları çalışmayacaktır.
1 2 3 4 5 6 7 8 9 | /** * AMP sayfalar için Google Adsense Ekleme */ function isa_load_amp_adsense_script( $data ) { $data[‘amp_component_scripts’][‘amp-ad’] = ‘https://cdn.ampproject.org/v0/amp-ad-0.1.js’; return $data; } add_filter( ‘amp_post_template_data’, ‘isa_load_amp_adsense_script’ ); |
Makalenin Başına Adsense Eklemek
Eğer adsense reklamını sayfanın başına eklemek istiyorsanız function.php dosyasına yukarıdaki koddan sonra aşağıdaki kodu ekleyip gerekli pub ve slot numaralarını değiştirmeniz yeterli olacaktır.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | /** * AMP sayfa başına Google Adsense Ekleme */ add_action( ‘pre_amp_render_post’, ‘isa_amp_add_content_filter’ ); function isa_amp_add_content_filter() { add_filter( ‘the_content’, ‘isa_amp_adsense_above_content’ ); } function isa_amp_adsense_above_content( $content ) { $publisher_id = ‘ca-pub-1234567891234567’; $ad_slot = ‘1234567890’; // Add Adsense ad above AMP content $ad_code = ‘<amp-ad layout=”fixed-height” height=”100″ type=”adsense” data-ad-client=”‘ . $publisher_id . ‘” data-ad-slot=”‘ . $ad_slot . ‘”></amp-ad>’; return $ad_code . $content; } |
Makalenin Ortasına Adsense Eklemek
Eğer reklamlarınızı makalenin tam ortasına mesela 2.paragraftan sonra, 4.paragraftan sonra gibi eklemek istiyorsanız, temanızın function.php dosyasının herhangi bir yerine aşağıdaki kodu ekleyip kayıt ediyoruz. 12. ve 14.satırdaki alanları kendi pub numaranızı ve reklam slot numaranız ile değiştirmeyi unutmayın.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 | /** * AMP makale içi Google Adsense Ekleme */ add_action( ‘pre_amp_render_post’, ‘isa_amp_add_content_filter’ ); function isa_amp_add_content_filter() { add_filter( ‘the_content’, ‘isa_amp_adsense_above_within_content’ ); } function isa_amp_adsense_above_within_content( $content ) { $publisher_id = ‘ca-pub-1234567891234567’; $ad_slot = ‘1234567890’; $ad_code_end = ‘ type=”adsense” data-ad-client=”‘ . $publisher_id . ‘” data-ad-slot=”‘ . $ad_slot . ‘”></amp-ad>’; // Above the fold ad code. This is fixed height as per Google guidelines for Adsense for AMP. $atf_ad_code = ‘<amp-ad layout=”fixed-height” height=”100″‘ . $ad_code_end; // Below the fold ad code. This is responsive as per Google guidelines for Adsense for AMP. $btf_ad_code = ‘<amp-ad layout=”responsive” width=”300″ height=”250″‘ . $ad_code_end; // Insert Adsense ad between the content, after paragraph 2 $new_content = isa_insert_after_paragraph( $btf_ad_code, 2, $content ); // Insert Adsense ad above AMP content return $atf_ad_code . $new_content; } function isa_insert_after_paragraph( $insertion, $paragraph_id, $content ) { $closing_p = ‘</p>’; $paragraphs = explode( $closing_p, $content ); foreach ($paragraphs as $index => $paragraph) { if ( trim( $paragraph ) ) { $paragraphs[$index] .= $closing_p; } if ( $paragraph_id == $index + 1 ) { $paragraphs[$index] .= $insertion; } } return implode( ”, $paragraphs ); } |