How can I display ads in amp pages - wordpress

I added this code to functions.php to perform the operation, but yet ads are not displaying on my amp pages.
//Adding Header Code in AMP pages in WordPress
add_action(‘amp_post_template_head’,’nhb_amp_my_custom_head’);
function nhb_amp_my_custom_head($amp_template) { ?> //adsense_header_code <?php }
//Adding Footer Code in AMP pages in WordPress
add_action(‘amp_post_template_footer’,’nhb_amp_my_custom_footer’);
function nhb_amp_my_custom_footer($amp_template) { ?> //adsense_body_code <?php }

You can display ads on your amp pages using the <amp-ad> or <amp-embed> tags.
A container to display an ad. The amp-embed is an alias to the amp-ad
tag, deriving all of its functionality with a different tag name. Use
amp-embed when semantically more accurate. AMP documents only support
ads/embeds served via HTTPS.
Example: Displaying a few ads
<amp-ad type="a9"
width="300"
height="250"
data-aax_size="300x250"
data-aax_pubname="test123"
data-aax_src="302">
</amp-ad>
<amp-ad width="300"
height="250"
type="industrybrains"
data-width="300"
data-height="250"
data-cid="19626-3798936394">
</amp-ad>
<amp-embed type="taboola"
width="400"
height="300"
layout="responsive"
data-publisher="amp-demo"
data-mode="thumbnails-a"
data-placement="Ads Example"
data-article="auto">
</amp-embed>
For more examples, you can try visiting this link.

Related

How to insert payments logo opencart footer

How can I insert payments logos in the footer for opencart 3.X?
you can Edit Footer Template file : catalog\view\theme\default\template\common\footer.twig
Replace
<p>{{ powered }}</p>
to
<p>{{ powered }}<img src="/image/yourimage path/yourimagename.png"
width="500" height="50" class="img-responsive" alt="Payment"
style="float:right"></p>
I think it will be working fine.
Edit footer template file catalog/view/theme/default/template/common/footer.tpl
Change
<p><?php echo $powered; ?></p>
to
<p><?php echo $powered; ?></font><img src="/image/yourimage path/yourimagename.png" width="480" height="40" class="img-responsive" alt="payment methods" style="float:right"></p>
May need to vary width\height as required
In 3.x if you have BurnEngine installed you can change it via BurnEngine -> Theme Settings -> Payment images.

Show another website in iFrame

I am trying to show a website on iFrame tag, it is working fine only at the landing page and while clicking on any page links it redirects me to the live website. I don't want it to redirect it to the live website. I am using the following code in php.
<iframe src="demo1.php" frameborder="0" >
</iframe>
<?php
$site = array('http://anusha.bluethink.in/b4bstaging/','http://anusha.bluethink.in/b4bstaging/personalised-balls.html');
$i=0;
foreach($site as $n) {
echo file_get_contents($site[$i]);
$i++;
}
?>

How to add multiple ads in Facebook Instant Articles using wordpress plugin?

I want to display multiple ads on Facebook instant articles. I found this code, which I tried manually and its working.
<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>
Now I am trying to make it possible via Facebook Instant Article Plugin. I didn't find any setting option for these type ads.
I tried to search on google and can't find anything except this:
https://developers.facebook.com/docs/instant-articles/sdk/transformer-rules
Please help me!
A. How to add multiple ads using FB INSTANT ARTICLE PLUGIN in wordpress?
B. How to add different codes using FB INSTANT ARTICLE PLUGIN in wordpress?
You can do this by adding the instant_articles_transformed_element filter, in order to modify the header accordingly.
This is generally used when placing Facebook Audience Network units, but if your manual code worked, the following code should work, although you might need to play around with the query vars. Add to functions.php the following:
At the top of functions.php, add this:
use Facebook\InstantArticles\Elements\Ad;
And then:
/**
* 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;
});
With that code, the plugin will take care of the rest, and it will automatically add the following code to the head section:
<meta property="fb:use_automatic_ad_placement" content="enable=true ad_density=default"/>
It will also add the following right before closing the header:
<section class="op-ad-template">
<figure class="op-ad op-ad-default">
<iframe src="https://www.mywebsite.com/ss?adtype=banner300x250&adSlot=1" width="300" height="250"></iframe>
</figure>
<figure class="op-ad">
<iframe src="https://www.mywebsite.com/ss?adtype=banner300x250&adSlot=2" width="300" height="250"></iframe>
</figure>
<figure class="op-ad">
<iframe src="https://www.mywebsite.com/ss?adtype=banner300x250&adSlot=3" width="300" height="250"></iframe>
</figure>
</section>

Customize Form within iFrame via CSS (iFrame contents not editable)

I need help customizing a form with CSS. The form was auto generated and cannot be edited. The iframe simply opens this form within so I cannot add CSS to the contact form to effect it. See link for the form:
label {
color: red;
}
input {
color: green;
}
<h2>Contact Us </h2>
<b style="color: red;">NOTE: I would like to modify the label font, input, and "required" text.</b> <br /> <br /><br />
<iframe name="lc_contact_form" frameborder="0" width="100%" height="600" src="https://sindesignphotography.17hats.com/embed/lead/form/nffgsxgpxrcxvcdwwcvwdpwhfvwwcfsz"></iframe><script type="text/javascript" src="https://sindesignphotography.17hats.com/js/lib/iframeSizer.min.js"></script>
Get Cross-Domain iFrame content
You can't access cross domain content. If it is comming from your own domain, you can. Run my code and look at the console log. It throws a security error. This is to prevent 3rd party webapplications from reading your bank account information.
$('#getStuff').contents().find("input").css('color', 'green')
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
Can't Access iframe
<iframe id="getStuff" name="lc_contact_form" frameborder="0" width="100%" height="600" src="https://sindesignphotography.17hats.com/embed/lead/form/nffgsxgpxrcxvcdwwcvwdpwhfvwwcfsz"></iframe>

Wordpress: how to make a post template with a fix image placement?

I am building a simple WP theme, but now I am stuck. I need to add an image on a fixed place for post_template A and 2 images on post_template B
Like so:
title
img
date
content
title
img img
date
content
Is it possible to make a template and on the admin side have the corresponding # of upload fields?
You can do that with custom fields...
In the edit page view add a custom field called "img1" for instance and the value should be the image url.
Then in your template A file you can output the image with:
<?php
$myimage = get_post_meta($post->ID, 'img1', true);
if ($myimage) { ?>
<img src="<?php echo $myimage; ?>" />
<?php } ?>
And in template B you just do that 2 times ;)

Resources