2017-09-26 3 views
0

Facebook 인스턴트 기사에 여러 광고를 표시하고 싶습니다. 수동으로 시도한이 코드를 발견했습니다.Facebook에 여러 광고를 추가하는 방법 인스턴트 기사 wordpress 플러그인을 사용하고 계십니까?

<section class="op-ad-template"> 

     <!-- Ads to be automatically placed throughout the article --> 

     <figure class="op-ad"> 
      <iframe src="https://www.mywebsite.com/ss;adtype=banner300x250&adslot=1" height="300" width="250"></iframe> 
     </figure> 

     <figure class="op-ad op-ad-default"> 
      <iframe src="https://www.mywebsite.com/ss;adtype=banner300x250&adslot=2" height="300" width="250"></iframe> 
     </figure> 

     <figure class="op-ad"> 
      <iframe src="https://www.mywebsite.com/ss;adtype=banner300x250&adslot=3" height="300" width="250"></iframe> 
     </figure> 

    </section> 

이제 Facebook Instant Article Plugin을 통해 가능하게하려고합니다. 이러한 유형의 광고에 대한 설정 옵션을 찾지 못했습니다.

내가 구글에서 검색을 시도하고이를 제외하고 아무것도 찾을 수 없습니다 https://developers.facebook.com/docs/instant-articles/sdk/transformer-rules

저를 도와주세요!

A. FB 인스턴트 기사 PLUGIN을 사용하여 여러 광고를 추가하는 방법은 무엇입니까?

B. FB를 사용하여 다른 코드를 추가하는 방법 FB INSTANT ARTICLE PLUGIN wordpress?

답변

0

헤더를 적절히 수정하려면 instant_articles_transformed_element 필터를 추가하면됩니다.

이것은 일반적으로 Facebook 사용자 네트워크 유닛을 배치 할 때 사용되지만 수동 코드가 작동하는 경우 쿼리 바를 가지고 놀 필요가 있지만 다음 코드가 작동해야합니다. 다음 functions.php에 추가 functions.php의 상단에

이 추가 : 다음

use Facebook\InstantArticles\Elements\Ad; 

과 :

/** 
* Adds multiple units to the Instant Article 
* 
* @param Instant_Articles_Post $article 
* 
* @return Instant_Articles_Post 
*/ 
add_filter('instant_articles_transformed_element', function ($article) { 
     // Create the base ad 
     $ad = Ad::create() 
       ->withWidth(300) 
       ->withHeight(250) 
       ->enableDefaultForReuse(); 

     // Retrieve the header 
     $article->getHeader() 
       // Add the first ad 
       ->addAd(
         $ad->withSource(
           // This creates the URL https://www.mywebsite.com/ss;adtype=banner300x250;adslot=1 
           add_query_arg(
             array(
              'adtype' => 'banner300x250', 
              'adSlot' => '1', 
             ), 

             'https://www.mywebsite.com/ss' 
           ) 
         ) 
       ) 
       // Add the second ad 
       ->addAd(
         $ad->withSource(
           // This creates the URL https://www.mywebsite.com/ss;adtype=banner300x250;adslot=2 
           add_query_arg(
             array(
              'adtype' => 'banner300x250', 
              'adSlot' => '2', 
             ), 

             'https://www.mywebsite.com/ss' 
           ) 
         ) 
       ) 
       // Add the third ad 
       ->addAd(
         $ad->withSource(
           // This creates the URL https://www.mywebsite.com/ss;adtype=banner300x250;adslot=3 
           add_query_arg(
             array(
              'adtype' => 'banner300x250', 
              'adSlot' => '3', 
             ), 

             'https://www.mywebsite.com/ss' 
           ) 
         ) 
       ); 

     return $article; 
}); 

을 그 코드와 플러그인이 걸릴 것입니다 나머지 부분을 돌보면 머리 섹션에 다음 코드가 자동으로 추가됩니다.

<meta property="fb:use_automatic_ad_placement" content="enable=true ad_density=default"/> 

또한 헤더를를 닫기 전에 다음의 권리를 추가합니다 :

그것의 내 웹 사이트 및 게시물의 페이스 북 즉시 제 옵션의 프론트 엔드에 나에게 빈 페이지를 보여주는
<section class="op-ad-template"> 
       <figure class="op-ad op-ad-default"> 
       <iframe src="https://www.mywebsite.com/ss?adtype=banner300x250&amp;adSlot=1" width="300" height="250"></iframe> 
       </figure> 
       <figure class="op-ad"> 
       <iframe src="https://www.mywebsite.com/ss?adtype=banner300x250&amp;adSlot=2" width="300" height="250"></iframe> 
       </figure> 
       <figure class="op-ad"> 
       <iframe src="https://www.mywebsite.com/ss?adtype=banner300x250&amp;adSlot=3" width="300" height="250"></iframe> 
       </figure> 
</section> 
+0

그냥 로딩 아이콘을 보여주고있다. 디버그 정보 나 다른 것을 볼 수 없습니다. –

+1

방금 ​​편집 한 답변 ... functions.php 상단에 추가해야합니다. Facebook \ InstantArticles \ Elements \ Ad를 사용하십시오. – luqita

+0

굉장! 이제 그 일. 이 코드를 설명해 주시겠습니까? 좀 제발 :) 그리고 고마워! –