fbpx

Adding ADS between WordPress Post Contents

Adding ADS between WordPress Post Contents
واتسآب
لينكدإن
فيسبوك
تويتر
تليجرام
الإيميل

Adding ADS between post contents in WordPress without using any plugins.

Most websites owners need to put their advertisements in different places of their own websites.

They need to put them between post content for visitors.

Follow the coming steps to do this:

  1. Open your theme folder.
  2. Open the file named “functions.php” into your code editor.
  3. Copy & paste the following function code before the closing php tag ?>:
function adsIntoPostContent($content){
if(is_single()){
$content_block = explode('<p>',$content);
if(!empty($content_block[2])) {
for($i=1;$i<count($content_block);$i++) {
$content_block[2] .= 'insert_the_AD_code_here';
}
$content = implode('',$content_block);
$content_block[$i] = '<p>'.$content_block[$i];
}
}
return $content;
}
add_filter('the_content', 'adsIntoPostContent');
  1. Replace the text string (( insert_the_AD_code_here )) into the function by the actual ad code.
  2. Save changes.
  3. Visit a post of your website to see your AD into your post.

Enjoy your advertisements.

تحميل المرفقات
لا يمكنك تحميل الملفات المرفقة ، برجاء تسجيل الدخول لتتمكن من التحميل
Lost your password?
[xs_social_login provider="facebook" class="facebook-login-btn"] [xs_social_login provider="google" class="google-login-btn"] [xs_social_login provider="linkedin" ]
أحدث المقالات

قد يعجبك أيضاً