AMP Posts/Pages Me Adsense Ads Insert Kaise Kare [Without Plugin]

आज हम आपको AMP posts/pages में Adsense Ads को insert करने के बारे में बताने जा रहे हैं. अगर आप भी अपने wordpress ब्लॉग में AMP का इस्तेमाल करते हो तो यह पोस्ट आपके लिए काफी helpful हो सकता है. हम आपको बिना किसी प्लगइन का इस्तेमाल किये ads insert करने के बारे में बताएँगे.

insert ads into amp post and pages without plugin

जब हम blogging की बात करते हैं तो सभी bloggers के लिए ads एक बहुत major thing होता है. हर कोई अपने ब्लॉग में मेहनत से पोस्ट लिखता है ताकि उन्हें उससे कुछ फायदा हो. हर blogger अपने ब्लॉग advertising दिखा करके या फिर affiliate marketing के द्वारा पैसे कमाते हैं.

ज्यादातर लोग अपने ब्लॉग में Advertising दिखाने के लिए Adsense का इस्तेमाल करते हैं. इसलिए आज हम आपको AMP pages में adsense का ads दिखाने के बारे में बताएँगे.

मुझसे अभी तक कई लोगों ने पूछा है की आप AMP pages में ads कैसे insert किये हो? कमेंट के माध्यम से में उन्हें सिर्फ इतना बता पाता था की “ये मेने manually coding से किया है” इसलिए आज उनलोगों के साथ आपको भी बताने वाला हूँ की AMP posts & pages में बिना प्लगइन के ads को कैसे दिखाएँ?

में अपने ब्लॉग में काफी समय से AMP का इस्तेमाल करता हूँ. इससे मुझे काफी positive result मिला है. चूँकि Google में amp को ख़ास मान्यता प्राप्त है. इसलिए mobile devices के लिए गूगल हमेशा amp pages पर ही ध्यान देता है.

अगर आपको इसके बारे में पता नहीं है तो मेने पहले से इसके बारे में पोस्ट लिख रखा है, आप उसे पढ़ सकते हो. साथ ही अगर आपको अपने ब्लॉग में amp को setup करना है तो आप इस पोस्ट को पढ़ सकते हो.

See also  WordPress Comment Form Se Website URL Field Aur Existing Comment URL Kaise Remove Kare

में अपने ब्लॉग में “AMP for WP” plugin का इस्तेमाल करता हूँ. ऊपर दिए पोस्ट को पढ़कर आप भी अपने ब्लॉग में इसे setup कर सकते हो.
फ़िलहाल, में आपको बताने वाला हूँ की AMP post & pages में ads कैसे दिखाएँ? अगर आप “AMP for WP” plugin का इस्तेमाल करते हो तो ही ये आपके लिए work करेगा. अगर आप amp के लिए दुसरे plugin का इस्तेमाल करते हो तो ये आपके लिए work नहीं भी कर सकता है. (हमने test नही किया है)

तो चलिए हम आपको इसके लिए बहुत simple process बताने वाले हैं. आपको इसके लिए किसी तरह के plugin का इस्तेमाल भी नहीं करना होगा. बस आपको कुछ codes को अपने theme में add करना होगा.

Insert Adsense Ads to AMP Pages without Plugin

इसके लिए कई सारे method हैं. आप plugin के माध्यम से भी insert कर सकते हो. लेकिन में आपको सबसे अच्छा तरीका बता रहा हूँ. इसके लिए आपको plugin के coding को edit भी नही करना होगा. जिससे plugin update होने के बाद आपको code खोने की समश्या हो.

AMP में adsense ads को दिखाने के लिए normal pages के मुकाबले काफी अलग है. इसलिए सबसे पहले में आपको इसके बारे में समझा देता हूँ.
सबसे पहले आपको Adsense में लॉग इन करके अलग अलग types के ads create कर लेना है. आपको Ad code से publisher id और ad slot को copy कर लेना है. Example के लिए आप निचे देख सकते हो.

<ins class="adsbygoogle"
style="display:block"
data-ad-client="ca-pub-7241177101992536"
data-ad-slot="8008299066"
data-ad-format="auto"
data-full-width-responsive="true"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>

ऊपर green color में adsense publisher id है और red color में ad slot है. सभी ads के publisher id same ही होंगे, आपको सिर्फ ad slot को नोट कर लेना है. चलिए अब हम आपको ads insert करने के बारे में बता रहे हैं.

See also  Genesis Theme Ko Manually Customize & Design Karne Ki Full Guide

अब आपको निचे दिए code को modify करके अपने ब्लॉग theme के functions.php में add करना होगा. चलिए इसको modify करने के बारे में जानते हैं.

/**
* Add Google Adsense code to AMP
*/
add_action( 'pre_amp_render_post', 'isa_amp_add_content_filter_alt' );
function isa_amp_add_content_filter_alt() {
add_filter( 'the_content', 'isa_amp_adsense_within_multiple' );
}
function isa_amp_adsense_within_multiple( $content ) {
$ad_units = array(
1 => 'XXXXXXXXXX',
10 => 'XXXXXXXXXX',
20 => 'XXXXXXXXXX',
30 => 'XXXXXXXXXX',
);
$insertions = array();
foreach ( $ad_units as $paragraph => $ad_slot ) {
$insertions[ $paragraph ] = '<amp-ad class="amp-ad-1" type="adsense" media="(max-width: 649px)" width=300 height=100 layout="responsive" data-ad-client="ca-pub-xxxxxxxxxxxxxxxx" data-ad-slot="' . $ad_slot . '"></amp-ad>';
}
// Insert Adsense ad after multiple paragraphs
$new_content = isa_insert_after_paragraph_multiple( $insertions, $content );
return $new_content;
}
function isa_insert_after_paragraph_multiple( $insertions = array(), $content ) {
$closing_p = '</p>';
$paragraphs = explode( $closing_p, $content );
foreach ($paragraphs as $index => $paragraph) {
if ( trim( $paragraph ) ) {
$paragraphs[$index] .= $closing_p;
}
// insert ad at multiple places
foreach ( $insertions as $paragraph_id => $ad_code ) {
if ( $paragraph_id === $index + 1 ) {
$paragraphs[$index] .= $ad_code;
}
}
}
return implode( '', $paragraphs );
}

जिस paragraph में ads insert करना है उसे blue color के number से replace कर सकते हो. हमने 1, 10, 20, 30 paragraph में ads insert कर रखा है. आप इसे अपने हिसाब से adjust कर सकते हो. Red color (XXXXXXXXXX) के जगह में अलग अलग ads के ad slot को replace करना होगा. उसके अलावा ca-pub-xxxxxxxxxxxxxxxx की जगह अपनी AdSense publisher id को add करना होगा.

अब आपके ब्लॉग म ads तो insert हो गये हैं लेकिन अभी ads show नही होगा. आपको निचे दिए गये code को अपने theme की functions.php में add करना होगा. उसके बाद ही आपके ब्लॉग ads show होगा.

/**
* Add the AMP Ad script to AMP pages.
*/
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' );

अब आपके ब्लॉग में ads show होने लगेंगे. इस तरह से बहुत आसानी से अपने amp पोस्ट और पेजेज में एड्स दिखा सकते हो. इसकी सबसे अच्छी बात ये है की जब भी plugin को update करोगे तो ads code remove नहीं होगा. क्योकि codes को हमने अपने theme के functions.php में add करके रखा है.

See also  Hosting cPanel Password Ko Change/Reset Kaise Kare

उम्मीद है की आपको ये पोस्ट पसंद आया होगा. इससे सम्बन्धित कोई सवाल पूछना है तो आप निचे comment कर सकते हो. अगर आपको पोस्ट पसंद आया है तो इसे social media में share जरुर करें. latest updates के लिए ब्लॉग के newsletter को join कीजिये.

Like the post?

Also read more related articles on BloggingHindi.com Sharing Is Caring.. ♥️

Sharing Is Caring...

2 thoughts on “AMP Posts/Pages Me Adsense Ads Insert Kaise Kare [Without Plugin]”

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.

×