M
M
max_mara2011-10-02 06:15:59
WordPress
max_mara, 2011-10-02 06:15:59

How to automatically change a specific expression to an adsense code block in Wordpress?

How to replace the html code of the pages with <!--Ad-->another html code (for example, adSense)?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
E
edogs, 2011-10-03
@edogs

There are blocks in the HTML code like
< !-- Ad — ->
I need to replace them with adSense code
There is a universal way.
At the beginning of the config or file index (in this case, wp-config ), insert something like ps: yes, it smacks of g-nocode, but in fact it is quite workable and kosher, and platform independence (from the engine) is even a plus.
ob_start("abazaba");
function abazaba($t) {
if(stristr($_SERVER['REQUEST_URI'],'wp-admin')) return $t; //что бы админку не портить
$a='код адсенса';
$t=str_replace('-- ad -- ',$a,$t); //злой парсер захавал нормальный ad
return $t;
}

S
startsevdenis, 2011-10-03
@startsevdenis

Wordpress has functions for working with shortcode, see here .

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question