
{"id":3968,"date":"2014-10-02T11:05:43","date_gmt":"2014-10-02T11:05:43","guid":{"rendered":"http:\/\/tapchicntt.com\/?p=3968"},"modified":"2014-10-02T11:07:14","modified_gmt":"2014-10-02T11:07:14","slug":"wordpress-them-tu-tai-tro-truoc-tieu-de-bai-viet","status":"publish","type":"post","link":"https:\/\/tapchicntt.com\/wordpress-them-tu-tai-tro-truoc-tieu-de-bai-viet\/","title":{"rendered":"[WordPress] Th\u00eam t\u1eeb &#8220;T\u00e0i Tr\u1ee3&#8221; tr\u01b0\u1edbc ti\u00eau \u0111\u1ec1 b\u00e0i vi\u1ebft"},"content":{"rendered":"<p>Hi\u1ec7n nay, c\u00e1c blogger th\u01b0\u1eddng c\u00f3 nh\u1eefng b\u00e0i vi\u1ebft \u0111\u01b0\u1ee3c tr\u1ea3 ti\u1ec1n. Nh\u1eefng b\u00e0i vi\u1ebft nh\u01b0 th\u1ebf h\u1ecd th\u01b0\u1eddng s\u1ebd th\u00eam t\u1eeb &#8220;T\u00e0i Tr\u1ee3&#8221;. Trong b\u00e0i vi\u1ebft n\u00e0y ch\u00fang t\u00f4i s\u1ebd h\u01b0\u1edbng d\u1eabn \u0111\u1ebfn c\u00e1c b\u1ea1n th\u00eam t\u1eeb &#8220;T\u00e0i Tr\u1ee3&#8221; v\u00e0o ti\u00eau \u0111\u1ec1 b\u00e0i vi\u1ebft trong wordpresss.<\/p>\n<p>Ch\u00fang ta s\u1ebd s\u1eed d\u1ee5ng Custom Fields \u0111\u1ec3 th\u00eam v\u00e0o ti\u00eau \u0111\u1ec1 b\u00e0i vi\u1ebft.<\/p>\n<p>Tr\u01b0\u1edbc ti\u00ean, b\u1ea1n t\u1ea1o m\u1ed9t b\u00e0i vi\u1ebft m\u1edbi ho\u1eb7c ch\u1ec9nh s\u1eeda n\u1ebfu c\u00f3 s\u1eb5n. Trong tr\u00ecnh so\u1ea1n th\u1ea3o b\u00e0i vi\u1ebft, di chuy\u1ec3n xu\u1ed1ng khu v\u1ef1c Custom Fields. N\u1ebfu b\u1ea1n kh\u00f4ng th\u1ea5y, b\u1ea1n nh\u1ea5n v\u00e0o n\u00fat &#8220;Screen Options&#8221; \u1edf g\u00f3c tr\u00ean b\u00ean ph\u1ea3i. M\u1ed9t Menu s\u1ebd m\u1edf ra, b\u1ea1n \u0111\u00e1nh d\u1ea5u ch\u1ecdn v\u00e0o Custom Fields.<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/cdn.wpbeginner.com\/wp-content\/uploads\/2014\/07\/customfields-screenoptions.png\" alt=\"\" \/><\/p>\n<p>Di chuy\u1ec3n xu\u1ed1ng khu v\u1ef1c Custom Fields,  Click v\u00e0o &#8220;Enter new&#8221; v\u00e0o th\u00eam v\u00e0o tab &#8220;Name&#8221; l\u00e0 &#8220;sponsored&#8221; v\u00e0 &#8220;Value&#8221; l\u00e0 &#8220;true&#8221;. Nh\u1ea5n v\u00e0o n\u00fat &#8220;Add Custom Field&#8221; \u0111\u1ec3 ho\u00e0n th\u00e0nh.<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/cdn3.wpbeginner.com\/wp-content\/uploads\/2014\/07\/customfields-metabox.png\" alt=\"\" \/><\/p>\n<p>Sau \u0111\u00f3, l\u01b0u b\u00e0i vi\u1ebft l\u1ea1i<\/p>\n<p>Ti\u1ebfp theo, b\u1ea1n m\u1edf file &#8220;functions.php&#8221; c\u1ee7a themes \u0111ang s\u1eed d\u1ee5ng v\u00e0 ch\u00e8n v\u00e0o \u0111o\u1ea1n code sau:<\/p>\n<pre class=\"brush: php; title: ; notranslate\" title=\"\">\r\n\r\nadd_filter( 'the_title', 'wpb_sponsored' );\r\nfunction wpb_sponsored( $title ) {\r\n   global $post;\r\n   $sponsored_text = '&lt;span class=&quot;sponsored_text&quot;&gt;T\u00e0i Tr\u1ee3 &lt;\/span&gt; ';\r\n   $sponsored = get_post_meta($post-&gt;ID, 'sponsored', true);\r\n   if( $sponsored == 'true' &amp;&amp; in_the_loop() ){\r\n       return $sponsored_text.$title;\r\n   }\r\n   return $title;\r\n}\r\n\r\n<\/pre>\n<p>M\u1edf file &#8220;style.css&#8221; c\u1ee7a theme \u0111\u1ec3 \u0111\u1ecbnh d\u1ea1ng cho \u0111\u1eb9p \u0111o\u1ea1n text hi\u1ec3n th\u1ecb.<\/p>\n<pre class=\"brush: css; title: ; notranslate\" title=\"\">\r\n\r\n.sponsored_text { \r\nbackground: #eeffee;\r\nfont-size:small;\r\ntext-transform: uppercase;\r\npadding:5px;\r\n}\r\n\r\n<\/pre>\n<p>N\u1ebfu c\u00e1c b\u1ea1n mu\u1ed1n t\u1eeb &#8220;T\u00e0i Tr\u1ee3&#8221; xu\u1ea5t hi\u1ec7n \u0111\u0103ng sau ti\u00eau \u0111\u1ec1 b\u1ea1n ch\u1ec9 c\u1ea7n ch\u1ec9nh \u0111o\u1ea1n code trong file &#8220;functions.php&#8221; l\u1ea1i nh\u01b0 sau:<\/p>\n<pre class=\"brush: php; title: ; notranslate\" title=\"\">\r\n\r\nadd_filter( 'the_title', 'wpb_sponsored' );\r\nfunction wpb_sponsored( $title ) {\r\n   global $post;\r\n   $sponsored_text = '&lt;span class=&quot;sponsored_text&quot;&gt; T\u00e0i Tr\u1ee3&lt;\/span&gt; ';\r\n   $sponsored = get_post_meta($post-&gt;ID, 'sponsored', true);\r\n   if( $sponsored == 'true' &amp;&amp; in_the_loop() ){\r\n       return $title . $sponsored_text;\r\n   }\r\n   return $title;\r\n}\r\n\r\n<\/pre>\n<p>Ch\u00fac c\u00e1c b\u1ea1n th\u00e0nh c\u00f4ng!<\/p>\n<p>Ngu\u1ed3n: wpbeginner.com<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Hi\u1ec7n nay, c\u00e1c blogger th\u01b0\u1eddng c\u00f3 nh\u1eefng b\u00e0i vi\u1ebft \u0111\u01b0\u1ee3c tr\u1ea3 ti\u1ec1n. Nh\u1eefng b\u00e0i vi\u1ebft nh\u01b0 th\u1ebf h\u1ecd th\u01b0\u1eddng s\u1ebd [&hellip;]<\/p>\n","protected":false},"author":6,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[143],"tags":[],"class_list":["post-3968","post","type-post","status-publish","format-standard","hentry","category-thu-thuat-wordpress"],"views":504,"_links":{"self":[{"href":"https:\/\/tapchicntt.com\/rest-api\/wp\/v2\/posts\/3968","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/tapchicntt.com\/rest-api\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/tapchicntt.com\/rest-api\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/tapchicntt.com\/rest-api\/wp\/v2\/users\/6"}],"replies":[{"embeddable":true,"href":"https:\/\/tapchicntt.com\/rest-api\/wp\/v2\/comments?post=3968"}],"version-history":[{"count":0,"href":"https:\/\/tapchicntt.com\/rest-api\/wp\/v2\/posts\/3968\/revisions"}],"wp:attachment":[{"href":"https:\/\/tapchicntt.com\/rest-api\/wp\/v2\/media?parent=3968"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/tapchicntt.com\/rest-api\/wp\/v2\/categories?post=3968"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/tapchicntt.com\/rest-api\/wp\/v2\/tags?post=3968"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}