本 blog 是使用由 Solostream 所制作的 Theme,其中廣告 ads 是由 wp_postmeta 中的 meta_key 控制。
如果想有分類廣告的話就非常麻煩,要逐個 post 設定、更改。
雖然以前學過 SQL 但是都已經還返哂俾老師,所以之前有更改都是花時間逐個 post 改。
不過隨著越來越多 post 已經不是辦法,所以都需要用 mysql 一次搞定。
不過比較麻煩的是控制 post Category 和 Postmeta 是由兩個不同 table 控制,所以需要 join table (幸好只要兩個而已)
科技世界
Top 728
UPDATE wp_postmeta JOIN wp_term_relationships
ON wp_postmeta.post_id = wp_term_relationships.object_id
SET wp_postmeta.meta_value = '<ins class="adsbygoogle t728ads"
data-ad-client="ca-pub-2100466215724212"
data-override-format="true"
data-ad-slot="6399129166"
data-ad-region="enterpr1se_head"
data-ad-format="auto"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>'
WHERE wp_term_relationships.term_taxonomy_id =436
AND wp_postmeta.meta_key = 'ad728_top'
Head 468
UPDATE wp_postmeta JOIN wp_term_relationships
ON wp_postmeta.post_id = wp_term_relationships.object_id
SET wp_postmeta.meta_value = '<ins class="adsbygoogle h468x60ads"
data-ad-client="ca-pub-2100466215724212"
data-override-format="true"
data-ad-slot="7875862367"
data-ad-region="enterpr1se_head"
data-ad-format="auto"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>'
WHERE wp_term_relationships.term_taxonomy_id =436
AND wp_postmeta.meta_key = 'ad468_header'
情感文章
Top 728
UPDATE wp_postmeta JOIN wp_term_relationships
ON wp_postmeta.post_id = wp_term_relationships.object_id
SET wp_postmeta.meta_value = '<ins class="adsbygoogle t728ads"
data-ad-client="ca-pub-2100466215724212"
data-override-format="true"
data-ad-slot="1829328762"
data-ad-region="enterpr1se_head"
data-ad-format="auto"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>'
WHERE wp_term_relationships.term_taxonomy_id =16
AND wp_postmeta.meta_key = 'ad728_top'
Head 468
UPDATE wp_postmeta JOIN wp_term_relationships
ON wp_postmeta.post_id = wp_term_relationships.object_id
SET wp_postmeta.meta_value = '<ins class="adsbygoogle h468x60ads"
data-ad-client="ca-pub-2100466215724212"
data-override-format="true"
data-ad-slot="3306061960"
data-ad-region="enterpr1se_head"
data-ad-format="auto"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>'
WHERE wp_term_relationships.term_taxonomy_id =16
AND wp_postmeta.meta_key = 'ad468_header'