开发者

How to insert Google Adsense in a single post after the <!--More--> Tag

开发者 https://www.devze.com 2023-03-16 09:02 出处:网络
I\'m using wordpress, and I want to add the adsense javascript tags where the Read More tag goes in a blogpost.It\'s stored as <!--more--> in the database, but when you use the_content() this is

I'm using wordpress, and I want to add the adsense javascript tags where the Read More tag goes in a blogpost. It's stored as <!--more--> in the database, but when you use the_content() this is automatically changed before I have the chance to use a str_replace() function.

I'm looking to place an adsense tag for each post in the single.php page where the teaser ends. Has anyone been able to do this? 开发者_如何学Go


  1. Create a filter on the content, to trigger text manipulation between retrieval and rendering.

  2. Define a shortcode to create something like [adsense] you can put in a post. When rendered WordPress calls your function, to replace the code by some text.

If every post must be changed use the filter. Use the shortcode if you want to be able to trigger replacement per post.

0

精彩评论

暂无评论...
验证码 换一张
取 消