0
Am Rückkehr der Publisher-ID von den Autoren Aufruf meta dh the_author_meta('pub-id', $author_id
Wie kann ich AdSense-Code von einer Funktion in Wordpress
CODE
//RECTANGLE Adsense UNit
function get_rectangle() {
global $post; $author_id=$post->post_author;
$rec_Ad.= '<div>';
$rec_Ad.= '<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- 300x250 -->
<ins class="adsbygoogle"
style="display:inline-block;width:300px;height:250px"';
if (get_the_author_meta('rectangle', $author_id)) {
$rec_Ad.= 'data-ad-client="ca-pub-'.the_author_meta('pub-id', $author_id).'"';
$rec_Ad.= 'data-ad-slot="'.the_author_meta('rectangle', $author_id).'"></ins>';
}
$rec_Ad.= '<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script></div>';
}
Der obige Code die Publisher-ID zurückgibt, aber nicht der ganze adsense code
Danke
habe ich versucht, dass und es gibt diesen HTML Code '91684956458900569117871855
' Die Zahlen, die Sie am Anfang zu sehen sind die 'Pub-id' und' slot' zusammen –bearbeitet gerade meine Antwort . Ich denke, das Problem war, dass "the_author_meta" verwendet wurde, um "get_the_author_meta" zu verwenden, da es den Wert direkt ausgibt. Siehe: https://developer.wordpress.org/reference/functions/the_author_meta/ – Quack
Vielen Dank. dieser Schnitt hat den Job erledigt –