Archived

This topic is now archived and is closed to further replies.

  • 0

<script> As Allowed Tags In Excerpt Doesn't Work

Question

Posted · Report post

I'm trying to put an adsense ad in an excerpt. I've added <script> as an allowed tag in the Pagelines settings. But it is removed anyway. What could be wrong? I'm not using any plugin that could interfere. And other text in excerpt is not removed.

Share this post


Link to post
Share on other sites

5 answers to this question

Posted · Report post

Hi,

I have to be honest and say that I have never tried to add javascript to an excerpt that way before. However, without evening trying, I don't think it would work, as javascript isn't HTML.

I would recommend you use a hook, to add your adsense to excerpts.

Share this post


Link to post
Share on other sites

Posted · Report post

I'm already adding the adsense code using a hook.


add_filter('the_content', 'appendAdSense');

function appendAdSense ($text) {

 if (is_archive()) {

 return $text . '<script type="text/javascript">...adsense code here...</script>';

 }

 return $text:

}


But the adsense code always is removed. Why?

Share this post


Link to post
Share on other sites

Posted · Report post

You can also try using a plugin from wordpress. Several of them have options to add ad units to excerpts. Ad Injection I think is one of them.

Share this post


Link to post
Share on other sites

Posted · Report post

Yes. But the problem seems to be in PageLines...

Share this post


Link to post
Share on other sites

Posted · Report post

You need to use an action not a filter.

pagelines_loop_after_excerpt


add_action( 'pagelines_loop_after_excerpt', 'appendAdSense' );
function appendAdSense() {
echo '<script type="text/javascript">...adsense code here...</script>';
}

[/CODE]

1 person likes this

Share this post


Link to post
Share on other sites