<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Học thiết kế web theo chuẩn. &#187; WordPress</title>
	<atom:link href="http://www.izwebz.com/category/wordpress/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.izwebz.com</link>
	<description>You aren&#039;t just a visitor</description>
	<lastBuildDate>Sat, 04 Feb 2012 12:43:17 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
		<item>
		<title>[WP Tip] Timthumb &amp; featured image</title>
		<link>http://www.izwebz.com/wordpress/wp-tip-timthumb-featured-image/</link>
		<comments>http://www.izwebz.com/wordpress/wp-tip-timthumb-featured-image/#comments</comments>
		<pubDate>Thu, 19 Jan 2012 12:00:18 +0000</pubDate>
		<dc:creator>Võ Minh Mẫn</dc:creator>
				<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://www.izwebz.com/?p=3387</guid>
		<description><![CDATA[Trên izwebz thì cũng có bài viết hướng dẫn cách sử dụng featured image để tạo thumbnail rồi. Nhưng trong bài viết này mình sẽ hướng dẫn các bạn kết hợp giữa timthumb và featured image để tạo ra những hình ảnh thumbnail hay sử dụng trong bài viết với kích thước có thể tùy [...]]]></description>
			<content:encoded><![CDATA[<p>Trên izwebz thì cũng có bài viết hướng dẫn cách sử dụng featured image để tạo thumbnail rồi. Nhưng trong bài viết này mình sẽ hướng dẫn các bạn kết hợp giữa timthumb và featured image để tạo ra những hình ảnh thumbnail hay sử dụng trong bài viết với kích thước có thể tùy chỉnh một cách thoải mái.<br />
<span id="more-3387"></span></p>
<div class="tutorial-image" style="font-size:20px;font-weight:bold;color:#AC2020;margin-bottom:10px">TIMTHUMB.PHP</div>
<p>Đây là một mã nguồn mở PHP với chức năng là crop và scale hình ảnh với các định dạng phổ biến như (JPG, PNG, GIF). Timthumb rất dễ dàng để sử dụng cho blog, website và một vài ứng dụng khác. Timthumb được phát triển bới Tim và Darren Hoyts, và nó đã liên tục nâng cấp các phiên bản để chữa lỗi, và thêm các tính năng mới.</p>
<p>Cách hoạt động: timthumb cung cấp cho bạn một function có sẵn, bạn chỉ việc cung cấp các tham số và nó sẽ tự động thay đổi kích thức ảnh của bạn một cách tự động.<br />
Timthumb đang được sử dụng rộng rãi đặc biệt là các nhà phát triển website trên nền CMS WordPress.</p>
<div class="tutorial-image" style="font-size:20px;font-weight:bold;color:#AC2020;margin-bottom:10px">CÁCH SỬ DỤNG TIMTHUMB.PHP</div>
<p>Điều đâu tiên mà bạn cần làm đó là phải download file timthumb.php về máy của mình để sử dụng. Bạn có thể download tại đây: <a href="http://timthumb.googlecode.com/svn/trunk/timthumb.php" target="_blank">http://timthumb.googlecode.com/svn/trunk/timthumb.php</a></p>
<p>Sau đó để có thể sử dụng nó bạn phải có 1 cái <a href="http://www.izwebz.com/video-tutorials/misc/appserv-network-cai-dat-va-su-dung/" target="_blank">localhost để chạy php</a>. Và bạn cần 1 tấm hình để có thao tác được với các chức năng đơn giản của timthumb. Và cuối cùng là một tạo folder cache nằm cùng cấp với file timthumb.php.</p>
<p><img src="http://farm8.staticflickr.com/7006/6683562063_0329f94451_z.jpg" alt="" /></p>
<p>Cấu trúc của timthumb thì như thế này:</p>
<pre class="brush: php; title: ;">&lt;img src=&quot;timthumb.php?src=link_hinh_anh.jpg&amp;amp;w=300&amp;amp;h=300&amp;amp;q=50&quot; /&gt;</pre>
<p>Giải thích các kí hiệu:</p>
<ul>
<li>link_hinh_anh.jpg – đường dẫn hình ảnh theo định dạng http://domain.com/hinhanh.jpg</li>
<li>w=300 – tức là width (chiều dài) của ảnh bằng 300px</li>
<li>h=300 – tức là height (chiều cao) của ảnh bằng 300px</li>
<li>q=50 – tức quality (chất lượng) của ảnh bằng 50% so với ảnh góc.</li>
</ul>
<p><img src="http://farm8.staticflickr.com/7141/6683660901_e2d68e0e0d_z.jpg" alt="" /></p>
<p>Tuy nhiên các bạn cũng có thể không cần phải dùng hết cả các tham số truyền ở trên.<br />
-	Nếu chỉ có width không thì nó sẽ tự động scale height hình cho hợp với chiều dài của hình và ngược lại.</p>
<pre class="brush: php; title: ;">&lt;img src=&quot;timthumb.php?src=link_hinh_anh.jpg&amp;amp;w=300&quot; /&gt;</pre>
<p>-	Nếu bạn để cả height và width thì nó sẽ vừa scale và crop hình của bạn lại cho phù hợp với width và height mà bạn chọn.</p>
<pre class="brush: php; title: ;">&lt;img src=&quot;timthumb.php?src=link_hinh_anh.jpg&amp;amp;w=300&amp;amp;h=300&quot; /&gt;</pre>
<p>-	Nếu các bạn ko để cả width height và quality thì nó sẽ để mặc định là width:100px; height:100px; quality:90%. Các bạn cũng có thể tìm và tùy chỉnh trong file timthumb.php các chỉ số mặc định trên.</p>
<pre class="brush: php; title: ;">&lt;img src=&quot;timthumb.php?src=link_hinh_anh.jpg&quot; /&gt;</pre>
<div class="tutorial-image" style="font-size:20px;font-weight:bold;color:#AC2020;margin-bottom:10px">TIMTHUMB.PHP &amp; FEATURED IMAGE</div>
<p><img src="http://farm8.staticflickr.com/7002/6683640595_8e64e06b94_z.jpg" alt="" /></p>
<p>Trước tiên, bạn phải bật chức năng Featured Image bằng cách vào file functions.php của wordpress và thêm đoạn code sau:</p>
<pre class="brush: php; title: ;"> add_theme_support( 'post-thumbnails' );</pre>
<p>Sau đó là chúng ta sẽ viết 1 hàm để <strong>lấy link của file Featured Image </strong>mà chúng ta add vào bài viết.</p>
<pre class="brush: php; title: ;">function get_featured_img($post_id){
$img_id = get_post_thumbnail_id($post_id); // lấy id của hình
$images=wp_get_attachment_image_src( $img_id, false, false ); // lấy link hình featured
return $images[0]; // 0: link hình ; 1: width ; 2: height
}
</pre>
<p>Tiếp theo, chúng ta sẽ viết thêm 1 hàm nữa để sử dụng <strong>timthumb với các tùy chỉnh width; height; quality; alt</strong></p>
<pre class="brush: php; title: ;">
function thumb_img($post_id,$h,$w,$q,$alt){
echo '&lt;img align=&quot;middle&quot; src=&quot;';
echo bloginfo('template_url');
echo '/timthumb.php?src='.get_featured_img($post_id).'&amp;amp;h='.$h.'&amp;amp;w='.$w.'&amp;amp;q='.$q.'&quot; alt=&quot;'.$alt.'&quot; /&gt;';
}</pre>
<p>Cuối cùng, để sử dụng thì chỉ việc gọi function thumb_img() ra thôi.<br />
Ví dụ như trong vòng lập Loop ở file single.php hay index.php thì chúng ta có thể gọi nó ra như thế này:</p>
<pre class="brush: php; title: ;">
&lt;?php $my_query = new WP_Query('posts_per_page=10');
if ( have_posts() ) : while ($my_query-&gt;have_posts()) : $my_query-&gt;the_post(); ?&gt; 

&lt;?php thumb_img($post-&gt;ID,'670','150','70',get_the_title()); ?&gt;
// $post-&gt;ID tương ứng với post id của bài viết.
// 670 tương ứng với chiều dài.
// 150 tương ứng với chiều cao.
// 70 tương ứng với chất lượng hình ảnh.
// get_the_title() lấy title của bài viết
&lt;?php endwhile; else: ?&gt;
&lt;?php endif; ?&gt;
</pre>
<p><a href="http://www.mediafire.com/?e3xqrb2asxnvc83" class="download">Download TimThumb Example</a></p>
<p>Vậy là chúng ta đã hoàn thành việc sử dụng featured image và timthumb. Hi vọng các bạn sẽ làm được thành công. Ngoài ra còn các các cách khác để sử dụng featured image làm thumbnail, các bạn có thể tham khảo.</p>
<ul>
<li><a href="http://www.izwebz.com/wordpress/tao-thumbnail-khong-dung-custom-field/" target="_blank">Tạo Thumbnail không dùng Custom Field</a></li>
<li><a href="http://www.izwebz.com/wordpress/tao-wordpress-theme-sidebar-va-thumbnail/" target="_blank">Thumbnail sử dụng Custom Field</a></li>
<li><a href="http://www.izwebz.com/wordpress/wordpress-post-thumbnail/" target="_blank">WordPress – Post Thumbnail</a></li>
<li><a href="http://www.izwebz.com/wordpress/tao-wordpress-theme-sidebar-va-thumbnail/" target="_blank">Tạo WordPress theme – Sidebar và Thumbnail</a></li>
</ul>
<div class="tutorial-image" style="font-size:20px;font-weight:bold;color:#AC2020;margin-bottom:10px">MỘT VÀI VÍ DỤ</div>
<p><a href="http://thethaohangnang.com" target="_blank"><img src="http://farm8.staticflickr.com/7168/6683022829_a0699739ee_z.jpg" alt="vI DU 1" /></a></p>
<p><a href="http://minhman.me" target="_blank"><img src="http://farm8.staticflickr.com/7175/6683022413_590ebe147f_z.jpg" alt="vi du 2" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.izwebz.com/wordpress/wp-tip-timthumb-featured-image/feed/</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
		<item>
		<title>[WP Tip] Thêm button vào post editor</title>
		<link>http://www.izwebz.com/wordpress/them-button-vao-post-editor/</link>
		<comments>http://www.izwebz.com/wordpress/them-button-vao-post-editor/#comments</comments>
		<pubDate>Tue, 10 Jan 2012 12:00:15 +0000</pubDate>
		<dc:creator>Võ Minh Mẫn</dc:creator>
				<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://www.izwebz.com/?p=3357</guid>
		<description><![CDATA[Editor của WordPress quả thật là rất tuyệt rồi, hổ trợ nhiều thứ. Bạn có thể copy/paste hay cũng có thể tự viết những dòng mã html/css ngay trên editor. Chỉ với nhưng cú nhấp chuột thì bạn có thể có được một bài viết được đăng tải lên mạng. Tuy nhiên, nó cũng có [...]]]></description>
			<content:encoded><![CDATA[<p>Editor của WordPress quả thật là rất tuyệt rồi, hổ trợ nhiều thứ. Bạn có thể copy/paste hay cũng có thể tự viết những dòng mã html/css ngay trên editor. Chỉ với nhưng cú nhấp chuột thì bạn có thể có được một bài viết được đăng tải lên mạng.<br />
<span id="more-3357"></span><br />
<img src="http://farm8.staticflickr.com/7151/6671145979_b2e89bf651_z.jpg" alt="Editor" /></p>
<p>Tuy nhiên, nó cũng có những thiếu sót, trong editor, như là không có thẻ p, hay thẻ h1, h2,&#8230;h6. Và trong tutorial hôm nay thì mình sẽ hướng dẫn các bạn cách edit để có thể dể dàng add những button với những dòng code hiển thị mà bạn mong muốn.</p>
<p><strong>Thời lượng:</strong> 10 phút<br />
<strong>File Size:</strong> 70 MB<br />
<strong>Screen size:</strong> HD 720p<br />
<strong>Download Mp4:</strong> <a href="http://www.mediafire.com/?rqu3jrlx39tulun" target="_blank">Mediafire</a><br />
<strong>Youtube:</strong><a href="http://www.youtube.com/watch?v=QSvteX1kqo4" target="_blank">http://www.youtube.com/watch?v=QSvteX1kqo4</a><br />
<strong>Vimeo:</strong><a href="http://vimeo.com/34830243" target="_blank">http://vimeo.com/34830243</a></p>
<div class="tutorial-image">
<p><iframe width="500" height="281" src="http://www.youtube.com/embed/QSvteX1kqo4?fs=1&#038;feature=oembed" frameborder="0" allowfullscreen></iframe></p>
</div>
<div class="tutorial-image">
<p>    <iframe src="http://player.vimeo.com/video/34830243" width="500" height="281" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe></p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.izwebz.com/wordpress/them-button-vao-post-editor/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>Chuyển tiêu đề sang hình ảnh &#8211; Free WP Plugin</title>
		<link>http://www.izwebz.com/wordpress/chuyen-tieu-de-sang-hinh-anh-free-wp-plugin/</link>
		<comments>http://www.izwebz.com/wordpress/chuyen-tieu-de-sang-hinh-anh-free-wp-plugin/#comments</comments>
		<pubDate>Wed, 08 Jun 2011 07:48:59 +0000</pubDate>
		<dc:creator>tanlevis</dc:creator>
				<category><![CDATA[WordPress]]></category>
		<category><![CDATA[Free Plugin]]></category>
		<category><![CDATA[tanlevis]]></category>
		<category><![CDATA[title to image]]></category>

		<guid isPermaLink="false">http://www.izwebz.com/?p=3021</guid>
		<description><![CDATA[Plugin này ra đời với mục đích giúp người sử dụng có nhiều sự lựa chọn font chữ hiển thị cho tiêu đề bài viết. Plugin với trang cấu hình đơn giản cho việc chọn font chữ, chọn font size, chọn màu chữ, màu nền mặc định cho file ảnh xuất ra. Đây cũng là [...]]]></description>
			<content:encoded><![CDATA[<p>Plugin này ra đời với mục đích giúp người sử dụng có nhiều sự lựa chọn font chữ hiển thị cho tiêu đề bài viết. Plugin với trang cấu hình đơn giản cho việc chọn font chữ, chọn font size, chọn màu chữ, màu nền mặc định cho file ảnh xuất ra. Đây cũng là một ví dụ đơn giản về viết plugin trong wp</p>
<p style="text-align: center"><img class="alignnone" src="https://lh6.googleusercontent.com/-jRtOWrYrAvg/TesvRrS0QAI/AAAAAAAAABk/S6QfE1JTfCs/s800/title-image-example.png" alt="" width="376" height="36" /><span id="more-3021"></span></p>
<p><strong>Cách sử dụng:</strong></p>
<ul>
<li>Cài đặt và kích hoạt plugin bình thường như những plugin khác.</li>
</ul>
<ul>
<li>Trong trang admin, chọn <strong>Themes/Giao diện</strong> chọn <strong>Title Image</strong> và thiết lập cấu hình mặc định cho file ảnh xuất ra.</li>
</ul>
<ul>
<li>Nếu muốn xuất ra hình ảnh chỗ nào thì ta đặt function sau ở chỗ phù hợp:</li>
</ul>
<pre class="brush: php; title: ;">if (function_exists('title_image'))
title_image('Plugin chuyển tiêu đề bài viết sang ảnh');
else
echo &quot;Plugin chuyển tiêu đề bài viết sang ảnh&quot;;</pre>
<ul>
<li>Nếu muốn plugin trả về địa chỉ hình ảnh ta gọi function với tham số như sau:</li>
</ul>
<pre class="brush: php; title: ;">$src = title_image('Plugin chuyển tiêu đề bài viết sang ảnh', false);</pre>
<ul>
<li>Cài đặt thêm font mới bằng cách upload file font vào thư mục <em>plugins/title-image/fonts </em>(sẽ hỗ trợ chức năng upload sau <img src='http://www.izwebz.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> ) .</li>
</ul>
<p><strong>Giải thích tham số:</strong></p>
<pre class="brush: php; title: ;">title_image($title, $echo = true, $size = 0, $textcolor = '',

$bgcolor = '', $font_name = '')</pre>
<p>- <strong>$title </strong>(string): chuỗi cần xuất ra file ảnh.</p>
<p>- <strong>$echo </strong>(true/false): có xuất ra tag img hay không? <strong>true</strong>: xuất ra tag img, <strong>false</strong>: trả về địa chỉ file ảnh.</p>
<p>- <strong>$size</strong> (int): kích thước font chữ.</p>
<p>- <strong>$textcolor</strong> (string): mã màu cho chữ vd: &#8217;000000&#8242;.</p>
<p>- <strong>$bgcolor</strong> (string): mã màu nền cho file hình ảnh vd: &#8216;ffffff&#8217;.</p>
<p>- <strong>$font_name </strong>(string): tên đầy đủ font chữ vd: verdana.ttf</p>
<p><strong>Chú ý:</strong></p>
<ul>
<li>Plugin sẽ lưu cache các file hình ảnh tại thư mục <em>plugins/title-image/temp </em>nhằm giúp tải trang nhanh hơn.</li>
<li>Nên cấp quyền cho thư mục <em>temp </em>với mã cmod: 755</li>
</ul>
<p><strong>Link download: <a title="Download Title Image" href="http://www.mediafire.com/?ft3d7cik2h62ynx" target="_blank"> </a></strong><a title="Download Title Image" href="http://www.mediafire.com/?ft3d7cik2h62ynx" target="_blank">http://www.mediafire.com/?ft3d7cik2h62ynx</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.izwebz.com/wordpress/chuyen-tieu-de-sang-hinh-anh-free-wp-plugin/feed/</wfw:commentRss>
		<slash:comments>20</slash:comments>
		</item>
		<item>
		<title>WP menu</title>
		<link>http://www.izwebz.com/wordpress/wp-menu/</link>
		<comments>http://www.izwebz.com/wordpress/wp-menu/#comments</comments>
		<pubDate>Tue, 24 May 2011 13:57:32 +0000</pubDate>
		<dc:creator>tanlevis</dc:creator>
				<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://www.izwebz.com/?p=2792</guid>
		<description><![CDATA[Trong tut này tôi giới thiệu sơ qua cách sử dụng nav-menu trong wordpress. Một tính năng rất chuyên nghiệp của WP 3.0. Hiệu quả nó mang lại thì xài rồi sẽ biết . Thời lượng: 16 phút Download định dạng .mp4 chất lượng cao : MediaFire Dung lượng: 10MB]]></description>
			<content:encoded><![CDATA[<p>Trong tut này tôi giới thiệu sơ qua cách sử dụng nav-menu trong wordpress. Một tính năng rất chuyên nghiệp của WP 3.0. Hiệu quả nó mang lại thì <img src='http://www.izwebz.com/wp-includes/images/smilies/icon_confused.gif' alt=':-?' class='wp-smiley' />  xài rồi sẽ biết <img src='http://www.izwebz.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> .</p>
<p><strong>Thời lượng:</strong> 16 phút<br />
<strong>Download định dạng .mp4 chất lượng cao :</strong> <a href="http://www.mediafire.com/?l56mycfetnp33c5" target="_blank">MediaFire</a><br />
<strong>Dung lượng:</strong> 10MB</p>
]]></content:encoded>
			<wfw:commentRss>http://www.izwebz.com/wordpress/wp-menu/feed/</wfw:commentRss>
		<slash:comments>28</slash:comments>
		</item>
		<item>
		<title>WordPress – Post Thumbnail</title>
		<link>http://www.izwebz.com/wordpress/wordpress-post-thumbnail/</link>
		<comments>http://www.izwebz.com/wordpress/wordpress-post-thumbnail/#comments</comments>
		<pubDate>Tue, 18 Jan 2011 03:25:44 +0000</pubDate>
		<dc:creator>Demon Warlock</dc:creator>
				<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://www.izwebz.com/?p=2707</guid>
		<description><![CDATA[Trước đây tôi đã hướng dẫn bạn cách sử dụng Custom Field để tạo post thumbnail, và cách dùng PHP để tự tạo thumbnail từ hình trong bài post. Tuy nhiên với WordPress từ phiên bản 2.9+ trở lên, bạn có thể sử dụng một tính năng mới để tạo post thumbnail đơn giản hơn [...]]]></description>
			<content:encoded><![CDATA[<p>Trước đây tôi đã hướng dẫn bạn cách sử dụng <a href="http://www.izwebz.com/wordpress/tao-wordpress-theme-sidebar-va-thumbnail/">Custom Field</a> để tạo post thumbnail, và cách <a href="http://www.izwebz.com/wordpress/tao-thumbnail-khong-dung-custom-field/">dùng PHP để tự tạo thumbnail</a> từ hình trong bài post. Tuy nhiên với WordPress từ phiên bản 2.9+ trở lên, bạn có thể sử dụng một tính năng mới để tạo post thumbnail đơn giản hơn nhiều. </p>
<p><span id="more-2707"></span></p>
<p><strong>Thời lượng</strong>: 5:30</p>
<p><strong>Download định dạng .mp4 chất lượng cao </strong>:<a href="http://www.mediafire.com/?frybmjj8h39al8k" target="_blank">MediaFire</a></p>
<p><strong>Dung lượng</strong>: 11 MB </p>
<div class="tutorial-image">
<iframe src="http://player.vimeo.com/video/17196689" width="580" height="480" frameborder="0"></iframe>
</div>
<h5>Code dùng trong Video</h5>
<p>Ban đầu bạn mở file <span class='post-span'>functions.php</span> trong theme của bạn ra và thêm dòng này vào trên cùng.</p>
<pre class="brush: php; title: ;">add_theme_support('post-thumbnails');
//nếu bạn muốn chỉ dùng với post
add_theme_support('post-thumbnails', array('post'));
//Nếu bạn muốn chỉ dùng với page
add_theme_support('post-thumbnails', array('page'));</pre>
<p>Tiếp theo bạn mở file single.php hoặc index.php và thêm đoạn mã sau vào TRONG WordPress Loop.</p>
<pre class="brush: php; title: ;">&amp;lt;?php the_post_thumbnail();?&amp;gt;
//Hoặc kiểm tra xem nó có tồn tại hay không trước khi in ra
&amp;lt;?php if(has_post_thumbnail()) {the_post_thumbnail();}?&amp;gt;</pre>
<p>Cuối cùng bạn có thể style cho nó bằng CSS với <span class='post-span'>class=&#8217;wp-post-image&#8217;</span></p>
]]></content:encoded>
			<wfw:commentRss>http://www.izwebz.com/wordpress/wordpress-post-thumbnail/feed/</wfw:commentRss>
		<slash:comments>23</slash:comments>
		</item>
		<item>
		<title>WordPress &#8211; Custom Post Type</title>
		<link>http://www.izwebz.com/wordpress/wordpress-custom-post-type/</link>
		<comments>http://www.izwebz.com/wordpress/wordpress-custom-post-type/#comments</comments>
		<pubDate>Fri, 14 Jan 2011 19:37:59 +0000</pubDate>
		<dc:creator>tanlevis</dc:creator>
				<category><![CDATA[WordPress]]></category>
		<category><![CDATA[Custom Post Type]]></category>
		<category><![CDATA[Taxonomy]]></category>

		<guid isPermaLink="false">http://www.izwebz.com/?p=2719</guid>
		<description><![CDATA[Phiên bản 3.0 của wordpress đã ra đời khá lâu rồi. Nhưng một trong những tính năng mạnh mẽ của phiên bản này không phải ai cũng biết, đó là Custom Post Type. Với tính năng này, bạn có thể thoái mái sáng tạo những cách quản lý bài viết trên WP. Ví dụ đơn [...]]]></description>
			<content:encoded><![CDATA[<p>Phiên bản 3.0 của wordpress đã ra đời khá lâu rồi. Nhưng một trong những tính năng mạnh mẽ của phiên bản này không phải ai cũng biết, đó là Custom Post Type. Với tính năng này, bạn có thể thoái mái sáng tạo những cách quản lý bài viết trên WP. Ví dụ đơn giản như tôi muốn quản lý 1 shop buôn bán thời trang nhỏ, hay 1 trang web môi giới nhà đất&#8230; Nhưng bằng những bài Post bình thường thì có thể làm được rồi. Tại sao phải dùng Custom Post Type?</p>
<p><span id="more-2719"></span></p>
<p>Câu trả lời đơn giản là ai cũng muốn phân loại những bài viết 1 cách sạch sẽ nhất, không muốn 1 bài viết về cái áo hiệu ABC lại đi nằm chung chỗ với 1 bài viết thuộc blog, nó khó quản lý, và tìm 1 bài viết nào đó để sửa cũng hơi lâu. Thay vì đó ta có thể tạo ra những &#8220;cái chuồng&#8221; <img src='http://www.izwebz.com/wp-includes/images/smilies/icon_neutral.gif' alt=':|' class='wp-smiley' /> , để nhốt chúng lại.</p>
<h2>1. Khai báo một Custom Post Type</h2>
<p>Để đăng ký với WP 1 post type mới ta nên khai báo trong file functions.php với cấu trúc tương tự như sau:</p>
<pre class="brush: php; title: ;">
/*Custom post type*/
  add_action('init', 'create_product_post_type');
  function create_product_post_type(){
    register_post_type('product',
      array(
        'labels'  =&gt;  array(
          'name'  =&gt;  __('Product'),
          'singular_name' =&gt;  __('Product'),
          'add_new' =&gt;  __('Add New'),
          'add_new_item'  =&gt;  __('Add New Product'),
          'edit'  =&gt;  __('Edit'),
          'edit_item' =&gt;  __('Edit Product'),
          'new_item'  =&gt;  __('New Product'),
          'view'  =&gt;  __('View Product'),
          'view_item' =&gt;  __('View Product'),
          'search_items' =&gt;  __('Search Products'),
          'not_found' =&gt;  __('No Products found'),
          'not_found_in_trash'  =&gt;  __('No Products found in Trash')
        ),
        'public'  =&gt;  true,
        'show_ui' =&gt;  true,
        'publicy_queryable' =&gt;  true,
        'exclude_from_search' =&gt;  false,
        'menu_position' =&gt; 20,
        'menu_icon' =&gt;  get_stylesheet_directory_uri(). '/images/product.png',
        'hierarchical'  =&gt; false,
        'query_var' =&gt;  true,
        'supports'  =&gt;  array(
          'title', 'editor', 'comments', 'author', 'excerpt', 'thumbnail',
          'custom-fields'
        ),
        'rewrite' =&gt;  array('slug'  =&gt;  'product', 'with_front' =&gt;  false),
        //'taxonomies' =&gt;  array('post_tag', 'category'),
        'can_export'  =&gt;  true,
        //'register_meta_box_cb'  =&gt;  'call_to_function_do_something',
        'description' =&gt;  __('Product description here.')
      )
    );
  }
</pre>
<p><strong>Dòng 2: </strong>Thông báo cho WP biết khi tạo trang admin thì sẽ chạy nội dung trong hàm &#8216;create_product_post_type&#8217;.</p>
<p><strong>Dòng 4: </strong>Hàm &#8216;register_post_type&#8217; nằm trong file wp-includes/post.php, tham số đầu là tên của post type, vd: product, tham số thứ 2 là một array. 1 điều lưu ý là tên của post type và custom taxonomy chúng ta nên viết ký tự thường.</p>
<p><strong>Dòng 7-18 : </strong>Định nghĩa lại các label xuất hiện trong trang quản lý Products</p>
<p><strong>Dòng 22: </strong>Cho phép query các Product bằng hàm query_posts().</p>
<p><strong>Dòng 24: </strong>Chọn vị trí xuất hiện của mục quản lý Products. Vị trí 20 là vị trí sau mục quản lý Pages</p>
<p><strong>Dòng 25: </strong>Địa chỉ icon(16&#215;16)</p>
<p><strong>Dòng 26: </strong>Có được phân cấp cha con hay không.</p>
<p><strong>Dòng 27: </strong>Biến để dùng trong phương thức GET, vd: mặc nhiên là ?product=&#8230;</p>
<p><strong>Dòng 28: </strong>Khai báo các meta box cho trang add new hay edit 1 product như: comments, author, custom-field, thumbnail &#8230;</p>
<p><strong>Dòng 32: </strong>Rewrite lại url khi query.</p>
<p><strong>Dòng 34: </strong>Có thể xuất nội dung ra file xml.</p>
<p><strong>Dòng 36: </strong>Diễn giải</p>
<h2>2. Thêm custom taxonomy vào Products</h2>
<p>Tôi đã có 1 bài viết giới thiệu về Custom taxonomy ở địa chỉ <a href="http://www.izwebz.com/wordpress/wordprescustom-taxonomies/" target="_blank">http://www.izwebz.com/wordpress/wordprescustom-taxonomies/</a>.Để đăng ký các custom taxonomy cho post type product, code có cấu trúc tương tự như sau:</p>
<pre class="brush: php; title: ;">
add_action('init', 'create_product_taxonomies');
  function  create_product_taxonomies(){
    register_taxonomy('brand', 'product', array(
      'hierarchical'  =&gt;  true,
      'labels'  =&gt;  array(
          'name'  =&gt;  __('Brand'),
          'singular_name' =&gt;  __('Brand'),
          'add_new' =&gt;  __('Add New'),
          'add_new_item'  =&gt;  __('Add New Brand'),
          'new_item'  =&gt;  __('New Brand'),
          'search_items' =&gt;  __('Search Brands'),
        ),
    ));
    register_taxonomy('size', 'product', array(
      'hierarchical'  =&gt;  false,
      'labels'  =&gt;  array(
          'name'  =&gt;  __('Size'),
          'singular_name' =&gt;  __('Size'),
          'add_new' =&gt;  __('Add New'),
          'add_new_item'  =&gt;  __('Add New Size'),
          'new_item'  =&gt;  __('New Size'),
          'search_items' =&gt;  __('Search Sizes'),
        ),
    ));

    register_taxonomy('price', 'product', array(
      'hierarchical'  =&gt;  false,
      'labels'  =&gt;  array(
          'name'  =&gt;  __('Price'),
          'singular_name' =&gt;  __('Price'),
          'add_new' =&gt;  __('Add New'),
          'add_new_item'  =&gt;  __('Add New Price'),
          'new_item'  =&gt;  __('New Price'),
          'search_items' =&gt;  __('Search Prices'),
        ),
    ));
  }
</pre>
<p><strong>Dòng 3: </strong>Đăng ký 1 custom taxonomy tên là brand, và post type là product và có phân cấp.</p>
<p>Tương tự đăng ký thêm 2 taxonomy size và brand. Về cơ bản với 2 code ở trên ta đã có một custom post type theo ý mình. Hãy thử tạo product, query_posts(), hiển thị lên trang xem như thế nào? <img src='http://www.izwebz.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> .</p>
<h2>3. Hiển thị bài post</h2>
<p>Với bài post mặc định thì khi được load WP sẽ dùng template file là  single.php để hiển thị nội dung. Nhưng với custom post type thì ta phải  khai báo một file có định dạng single-tên-custom-post-pype.php (vd:  single-product.php với product là tên  custom post type). Trong file này  ta có thể xài vòng loop bình thường mà ai xài WP cũng thuộc lòng <img src='http://www.izwebz.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> </p>
<pre class="brush: php; title: ;">
if (have_posts()){
  while (have_posts()){
  the_post();
//xuất nội dung của post ở đây.
}
}else{
echo &quot;No posts found&quot;;
}
</pre>
<p>Từ dòng 4 trở đi thì ta có thể xài các template tag mặc định của WP để kéo nội dung của custom post type ra.</p>
<h2>4. Trình bày danh sách dạng archive.php</h2>
<p>Phiên bản hiện tại của WP là 3.0.3, với phiên bản này thì WP không hỗ  trợ archive cho custom post type. Theo lời giới thiệu của một số developer đang làm core của WP thì  phiên bản 3.1 mới có hỗ trợ chức năng này. Tuy nhiên hiện tại thì có 2  plugins hỗ trợ ta làm việc này. Một trong số chúng mà tôi thấy dễ xài là <a href="http://www.cmurrayconsulting.com/software/wordpress-custom-post-type-archives/" target="_blank"><strong>Simple Custom Post Type Archives</strong></a>, sau khi kích hoạt plugin này thì ta phải tạo file dạng: <big>type-tên-custom-post-type.php (vd: type-product.php) và lưu ở thư mục theme.</big></p>
<p>Nội dung file ta có thể sử dụng vòng loop để hiển thị danh sách các bài post bình thường như file archive.php</p>
<h2>5. query_posts với custom post type</h2>
<p>Đoạn code sau sẽ thực hiện truy vấn những bài post thuộc post type là  product, có title hoặc content chứa chữ izwebz, và số post hiển thị là  10</p>
<pre class="brush: php; title: ;">
//function dùng để filter
function filter_where($where = '') {
  //post_title, post_content like '%izwebz%'
  $text = 'izwebz';
  $where .= &quot; AND (post_title like '%$text%' OR post_content like '%$text%')&quot;;
return $where;
}
// đăng ký filter với WP
add_filter('posts_where', 'filter_where');
$paged = (get_query_var('paged')) ? get_query_var('paged') : 0;
$args = array('post_type' =&gt;  'product', 'paged' =&gt; $paged,'showposts' =&gt;  10 );
query_posts($args);
if(have_posts()){
   while(have_posts()){
     the_post();
     //xuất nội dung ở đây
   }
}else{
   echo &quot;No products found&quot;;
}
//nhớ reset query sau khi xai query_posts()
wp_reset_query();
</pre>
<p>Dòng 9: Đăng ký filter với WP. Đây là 1 kỹ thuật hook cực hay của WP. Nếu sau bài viết này chưa có ai giới thiệu về hook thì tôi xin tình nguyện giới thiệu chúng trong bài tiếp theo \:D/.</p>
<h2>5. Lời kết</h2>
<p>Custom post type đã mở ra cho người lập trình hướng WP một lối xây dựng  cách quản lý bài viết rất riêng, không phụ thuộc quá vào cách quản lý  Posts bình thường. Nếu có thắc mắc về bài viết thì mọi người hãy để lại  comment để cộng đồng izwebz giúp đỡ. Hy vọng bài viết mang lại chút kiến  thức mới cho mọi người. Cảm ơn đã đọc bài viết <img src='http://www.izwebz.com/wp-includes/images/smilies/icon_neutral.gif' alt=':|' class='wp-smiley' /> </p>
<p>Các bác có thể tham khảo API WP ở đây:</p>
<p><a href="http://codex.wordpress.org/Function_Reference/register_post_type" target="_blank">http://codex.wordpress.org/Function_Reference/register_post_type</a></p>
<p><a href="http://codex.wordpress.org/images/1/18/Template_Hierarchy.png" target="_blank"> http://codex.wordpress.org/images/1/18/Template_Hierarchy.png</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.izwebz.com/wordpress/wordpress-custom-post-type/feed/</wfw:commentRss>
		<slash:comments>31</slash:comments>
		</item>
		<item>
		<title>WordPress Tut &#8211; Shortcode</title>
		<link>http://www.izwebz.com/wordpress/wordpress-tut-shortcode/</link>
		<comments>http://www.izwebz.com/wordpress/wordpress-tut-shortcode/#comments</comments>
		<pubDate>Mon, 10 Jan 2011 15:32:00 +0000</pubDate>
		<dc:creator>Demon Warlock</dc:creator>
				<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://www.izwebz.com/?p=2731</guid>
		<description><![CDATA[Được đưa vào trong WordPress từ phiên bản 2.5, shortcode là một tính năng mạnh mẽ nhưng lại ít được biết đến của WordPress. Việc sử dụng shortcode rất đơn giản, ví dụ bạn chỉ cần gõ [google_map] là nó sẽ tự động hiện ra địa chỉ mà bạn thiết lập từ trước. Đặc biệt [...]]]></description>
			<content:encoded><![CDATA[<p>Được đưa vào trong WordPress từ phiên bản 2.5, shortcode là một tính năng mạnh mẽ nhưng lại ít được biết đến của WordPress. Việc sử dụng shortcode rất đơn giản, ví dụ bạn chỉ cần gõ [google_map] là nó sẽ tự động hiện ra địa chỉ mà bạn thiết lập từ trước.</p>
<p><span id="more-2731"></span></p>
<p>Đặc biệt khi bạn phát triển theme để bán cho khách hàng và khách hàng của bạn không biết gì về code. Bạn có thể tạo ra shortcode và họ có thể chèn những gì họ muốn một cách rất đơn giản mà không phải đả động đến code. Khi sử dụng shortcode bạn phải ở trong phần soạn thảo HTML và chèn vào đoạn shortcode mong muốn.</p>
<p>Trong video trước chúng ta đã học về những bước cơ bản để tạo một WordPress Plugin, trong video này chúng ta sẽ học cách tạo shortcode. Bạn có thể tham khảo thêm về shortcode tại trang <a href="http://codex.wordpress.org/Shortcode_API" target="_blank">WordPress Codex: Shortcode API</a> và <a href="http://code.google.com/apis/maps/documentation/staticmaps/" target="_blank">Google Maps API</a>.</p>
<p><strong>Thời lượng</strong>: 18 phút</p>
<p><strong>Download định dạng .mp4 chất lượng cao</strong>: <a href="http://www.mediafire.com/?8hab56fd2f0lbu4" target="_blank">Mediafire</a></p>
<p><strong>Dung lượng</strong>: 31 MB </p>
<div class="tutorial-image">
<iframe src="http://player.vimeo.com/video/17788774" width="580" height="480" frameborder="0"></iframe>
</div>
<h5>Đoạn code trong video</h5>
<pre class="brush: php; title: ;">&lt;?php

/*
Plugin Name: Google Maps Shortcode
Plugin URI: http://www.izwebz.com/plugin
Description: Display Google maps Shortcode
Version: 1.0
Author URI: http://www.izwebz.com
*/

function iz_google_maps($atts, $content=null) {
    extract(shortcode_atts(array(
        'title' =&gt; 'My location',
        'address' =&gt; '1600 NW 122 Oklahoma City, OK'
    ),$atts));
    return &quot;&lt;h2&gt;{$title}&lt;/h2&gt;
    &lt;img src='http://maps.google.com/maps/api/staticmap?zoom=14&amp;size=300x300&amp;sensor=false&amp;center={$address}' alt='my location' /&gt;&quot;;
}

add_shortcode('google_map','iz_google_maps');

?&gt;</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.izwebz.com/wordpress/wordpress-tut-shortcode/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
		<item>
		<title>WordPress Tut &#8211; Viết WP Plugin</title>
		<link>http://www.izwebz.com/wordpress/viet-wordpress-plugin/</link>
		<comments>http://www.izwebz.com/wordpress/viet-wordpress-plugin/#comments</comments>
		<pubDate>Mon, 03 Jan 2011 15:00:32 +0000</pubDate>
		<dc:creator>Demon Warlock</dc:creator>
				<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://www.izwebz.com/?p=2727</guid>
		<description><![CDATA[Trước đây tôi có làm một Video Series về tạo WordPress Theme, trong series lần này chúng ta sẽ học cách tạo WordPress Plugin và Widget. Tại sao chúng ta phải tạo Plugin khi mà WordPress đã có rất nhiều Plugin miễn phí? Câu trả lời có thể là chúng ta chỉ muốn biết cách [...]]]></description>
			<content:encoded><![CDATA[<p>Trước đây tôi có làm một Video Series về tạo WordPress Theme, trong series lần này chúng ta sẽ học cách tạo WordPress Plugin và Widget. Tại sao chúng ta phải tạo Plugin khi mà WordPress đã có rất nhiều Plugin miễn phí?</p>
<p><span id="more-2727"></span></p>
<p>Câu trả lời có thể là chúng ta chỉ muốn biết cách tạo ra một Plugin như thế nào. Hoặc những Plugin miễn phí không thỏa mãn những yêu cầu của bạn về một Plugin. Cho dù mục đích của bạn là như thế nào đi chăng nữa, thì việc học cách tạo một Plugin cho WordPress không khó như bạn tưởng. Trong video này tôi sẽ hướng dẫn bạn những bước cơ bản nhất để tạo ra một WordPress Plugin từ vạch xuất phát.</p>
<p><strong>Thời lượng</strong>: 26:30</p>
<p><strong>Download định dạng .mp4 chất lượng cao </strong>:<a href="http://www.mediafire.com/?ba369mk5d89rmbx" target="_blank">Mediafire</a></p>
<p><strong>Dung lượng</strong>: 34 MB/ phần </p>
<p>Link trong Video: <a href="http://adambrown.info/p/wp_hooks" target="_blank">Adam Brown</a></p>
<div class="tutorial-image">
<iframe src="http://player.vimeo.com/video/17697047" width="580" height="480" frameborder="0"></iframe>
</div>
<h5>Mô hình Action và Filter hook của WordPress</h5>
<div class="tutorial-image"><img src="http://www.izwebz.com//wp-content/uploads/demon/images/wordpress-action/action-filter.png" alt="wordpress plugin development" /></div>
<h5>Những Filter hooks phổ biến</h5>
<ul>
<li><strong>the_content</strong>: thay đổi nội dung của post hoặc page trước khi hiển thị nó.</li>
<li><strong>the_content_rss</strong>: thay đổi nội dung của post hoặc page cho RSS.</li>
<li><strong>the_title</strong>: thay đổi nội dung tiêu đề của post hoặc page trước khi hiển thị nó.</li>
<li><strong>comment_text</strong>: thay đổi nội dung của comment trước khi hiển thị nó.</li>
<li><strong>wp_title</strong>: thay đổi nội dung của thẻ <span class='post-span'>&lt;title&gt;</span> trước khi hiển thị nó.</li>
<li><strong>get_categories</strong>: thay đổi nội dung của list tạo ra bởi hàm <span class='post-span'>get_categories</span>.</li>
<li><strong>the_permalink</strong>: thay đổi cấu trúc URL của đường liên kết.</li>
</ul>
<h5>Những Action hooks phổ biến</h5>
<ul>
<li><strong>publish_post</strong>: gọi hàm khi bạn tạo một post mới.</li>
<li><strong>create_categories</strong>: gọi hàm khi một Category mới được tạo.</li>
<li><strong>switch_theme</strong>: gọi hàm khi thay đổi theme.</li>
<li><strong>admin_head</strong>: gọi hàm trong thẻ <span class='post-span'>&lt;head&gt;</span> của trang Admin.</li>
<li><strong>wp_head</strong>: gọi hàm trong thẻ <span class='post-span'>&lt;head&gt;</span> của theme.</li>
<li><strong>wp_footer</strong>: gọi hàm dưới phần footer của trang, thường nằm trên thẻ <span class='post-span'>&lt;/body&gt;</span>.</li>
<li><strong>init</strong>: gọi hàm sau khi WordPress đã tải xong nội dung, nhưng trước khi nó gửi ra headers. Thường được dùng để tương tác với <span class='post-span'>$_GET</span> hoặc <span class='post-span'>$_POST</span>.</li>
<li><strong>admin_init</strong>: giống với init nhưng chỉ áp dụng với trang admin.</li>
<li><strong>user_register</strong>: gọi hàm khi có người đăng ký thành viên.</li>
<li><strong>comment_post</strong>: gọi hàm khi có người post comment.</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.izwebz.com/wordpress/viet-wordpress-plugin/feed/</wfw:commentRss>
		<slash:comments>32</slash:comments>
		</item>
		<item>
		<title>WordPress &#8211; Cắt ngắn post nhiều nội dung</title>
		<link>http://www.izwebz.com/wordpress/wordpress-cat-ngan-noi-dung/</link>
		<comments>http://www.izwebz.com/wordpress/wordpress-cat-ngan-noi-dung/#comments</comments>
		<pubDate>Mon, 13 Dec 2010 04:35:47 +0000</pubDate>
		<dc:creator>Demon Warlock</dc:creator>
				<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://www.izwebz.com/?p=2700</guid>
		<description><![CDATA[Tuy WordPress là một dạng Blog Platform nhưng nó cũng thường được sử dụng như là một CMS. Do vậy đôi khi có những bài post quá dài và bạn muốn phân nó ra làm nhiều trang nhỏ hơn đễ người đọc tiện theo dõi hơn và cũng dễ đọc hơn. Đây là một tính [...]]]></description>
			<content:encoded><![CDATA[<p>Tuy WordPress là một dạng Blog Platform nhưng nó cũng thường được sử dụng như là một CMS. Do vậy đôi khi có những bài post quá dài và bạn muốn phân nó ra làm nhiều trang nhỏ hơn đễ người đọc tiện theo dõi hơn và cũng dễ đọc hơn.
</p>
<p><span id="more-2700"></span></p>
<p>Đây là một tính năng hay nhưng lại ít được biết đến của WordPress, có thể bởi vì ít có post nào dài đến mức mà phải cần phân trang. Nhưng như bạn thấy trên izwebz, loạt bài về jQuery có những post rất dài và làm chậm tốc độ load của trang. Trong bài này chúng ta sẽ học cách phân trang này ra để tạo ra các trang ngắn hơn. Bạn có thể <a href="http://www.izwebz.com/jquery/chuong-6-ajax/" target="_blank">xem ví dụ</a> trước để hiểu chúng ta cần làm cái gì, bạn kéo xuống dưới cùng của post để thấy đoạn phân trang.</p>
<p>Để làm được việc này chính xác hơn, bạn cần chuyển sang chế độ soạn thảo mã <strong>HTML</strong> thay vì <strong>Visual</strong>. Sau đó bạn chền đoạn mã sau vào nơi bạn cần phân trang.</p>
<pre class="brush: xml; title: ;">&lt;!--nextpage--&gt;</pre>
<p>Trước khi bạn có thể xem được kết quả, bạn cần phải chỉnh sửa lại mã nguồn của nó một chút. Bạn hãy mở file <span class='post-span'>single.php</span> và thêm đoạn mã dưới đây vào <strong>trong</strong> vòng lặp Loop của WordPress. </p>
<pre class="brush: php; title: ;">&lt;?php wp_link_pages(); ?&gt;</pre>
<p>Nếu bạn chỉ dùng hàm wp_link_pages() mà không có tham số thì nó sẽ cho ra dạng trang mặc định kiểu như: <strong>Pages</strong>: 1 2 3. Hoặc bạn cũng có thể thêm các tham số vào để tùy biến cho nó. Những tham số của nó như sau:</p>
<pre class="brush: php; title: ;">&lt;?php $args = array(
    'before'           =&gt; '&lt;p&gt;' . __('Pages:'),
    'after'            =&gt; '&lt;/p&gt;',
    'link_before'      =&gt; ,
    'link_after'       =&gt; ,
    'next_or_number'   =&gt; 'number',
    'nextpagelink'     =&gt; __('Next page'),
    'previouspagelink' =&gt; __('Previous page'),
    'pagelink'         =&gt; '%',
    'more_file'        =&gt; ,
    'echo'             =&gt; 1 ); ?&gt;</pre>
<p><strong>before</strong>: (chuỗi) Chữ bạn muốn hiển thị trước các số trang. Mặc định là &lt;p&gt;Pages:<br />
<strong>after:</strong> Chữ sẽ xuất hiện sau các số trang. Mặc định là &lt;/p&gt;.<br />
<strong>link_before và link_after</strong>: (chuỗi) Các ký tự xuất hiện trước hoặc sau số trang. Có thể bạn muốn các số trang phân cách nhau bằng dấu , hoặc | chẳng hạn.<br />
<strong>next_or_number:</strong> (chuỗi) Bạn có hai lựa chọn là hiển thị số hoặc hiển thị chữ Next. Giá trị mặc định là number và next.</p>
<h5>Ví dụ</h5>
<p>Hiển thị số trang với thẻ p bao quanh</p>
<pre class="brush: php; title: ;">&lt;?php wp_link_pages('before=&lt;p&gt;&lt;strong&gt;Trang:&lt;/strong&gt;&amp;after=&lt;/p&gt;&amp;next_or_number=number&amp;pagelink= %'); ?&gt;</pre>
<p>Hiển thị dưới dạng Next và Previous</p>
<pre class="brush: php; title: ;">&lt;?php wp_link_pages('next_or_number=next');?&gt;</pre>
<h5>Tham khảo thêm WordPress Codex</h5>
<p>Bạn có thể xem thêm về cách sử dụng hàm này tại trang <a href="http://codex.wordpress.org/Function_Reference/wp_link_pages" target="_blank">WordPress Codex</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.izwebz.com/wordpress/wordpress-cat-ngan-noi-dung/feed/</wfw:commentRss>
		<slash:comments>25</slash:comments>
		</item>
		<item>
		<title>WordPress – Custom Taxonomies</title>
		<link>http://www.izwebz.com/wordpress/wordprescustom-taxonomies/</link>
		<comments>http://www.izwebz.com/wordpress/wordprescustom-taxonomies/#comments</comments>
		<pubDate>Thu, 25 Nov 2010 16:53:34 +0000</pubDate>
		<dc:creator>tanlevis</dc:creator>
				<category><![CDATA[WordPress]]></category>
		<category><![CDATA[Taxonomy]]></category>

		<guid isPermaLink="false">http://www.izwebz.com/?p=2704</guid>
		<description><![CDATA[Chào mọi người. Hôm nay tanlevis xin giới thiệu 1 chức năng rất hay của wordpress – Custom taxonomy. Taxonomy là gì? taxonomy là 1 cách để phân loại những bài viết trong wordpress, ví dụ các taxonomies mặc định của WP như: Categories, Post tags. Taxonomy vô cùng quan trọng trong việc thể hiện [...]]]></description>
			<content:encoded><![CDATA[<p>Chào mọi người. Hôm nay tanlevis xin giới thiệu 1 chức năng rất hay của wordpress – Custom taxonomy.</p>
<p><span id="more-2704"></span></p>
<h5>Taxonomy là gì?</h5>
<ul>
<li>taxonomy là 1 cách để phân loại những bài viết trong wordpress, ví dụ các taxonomies mặc định của WP như: Categories, Post tags.</li>
<li>Taxonomy vô cùng quan trọng trong việc thể hiện những bài post trong wp theo ý muốn của mình, ví dụ như 1 shop thời trang nhỏ như http://www.valentineyogurt.com/test/  </li>
</ul>
<h5>Ứng dụng</h5>
<p>Trong bài viết này mình có demo những gì mình đã viết ở địa chỉ http://www.valentineyogurt.com/test/, các bạn có thể login vào để thử, user: test, pass: 123456.</p>
<div class="tutorial-image"><img src="http://www.izwebz.com/wp-content/uploads/tanlevis/taxonomies.png" alt="custom taxonomies" /></div>
<h5>Cách sử dụng</h5>
<p>- Mở file function.php trong thư mục theme của  bạn, thêm đoạn code sau vào phần cuối file (nhớ là trước dấu ?&gt;)</p>
<p>.</p>
<pre class="brush: php; title: ;">// Custom taxonomy for Size
  register_taxonomy('Size', 'post',  array(
    'hierarchical' =&gt; true, 'label' =&gt; 'Size',
    'query_var' =&gt;  true, 'rewrite' =&gt; true));

  // Custom taxonomy for Price
  register_taxonomy('Price', 'post',  array(
    'hierarchical' =&gt; false, 'label' =&gt; 'Price',
    'query_var'  =&gt; true, 'rewrite' =&gt; true));

  // Custom taxonomy for Brand
  register_taxonomy('Brand', 'post',  array(
    'hierarchical' =&gt; true, 'label' =&gt; 'Brand',
    'query_var'  =&gt; true, 'rewrite' =&gt; true));
</pre>
<p><span class='post-span'>function register_taxonomy($taxonomy, $object_type, $args = array()):</span> có chức năng đăng ký 1 taxonomy mới.</p>
<p><strong>$taxonomy</strong>: tên taxonomy (vd: Size).<br />
<strong>$object_type:</strong> đối tượng mà taxonomy quản lý (vd: post, page, link, custom post type).<br />
<strong>$args = array()</strong>: mảng các tham số như:<br />
<strong>‘hierarchical&#8217; =&gt; true | false</strong>: có được phân cấp như Categories hay không.<br />
<strong>‘label&#8217;</strong>: Nhãn hiển thị trong option panel, vd: Size, Price, Brand. ..v..v.. các bạn có thể tham khảo tại đây: http://codex.wordpress.org/Function_Reference/register_taxonomy</p>
<p>
Khi đăng ký xong hãy vào dashboard, vào mục Posts và hãy nhìn xem chúng ta có gì? Đó là 3 taxonomy với tên (Size, Price, Brand) vừa đăng ký ở trên. Chúng giống như quản lý Tags, hay là Categories vậy.</p>
<p>Hiển thị taxonomy: Mở file index.php, tìm đoạn code nơi xuất ra những bài post, thêm code dưới đây vào trong vòng loop:</p>
<pre class="brush: php; title: ;">//hiển thị hình ảnh sản phẩm
&lt;?php if(has_post_thumbnail()):?&gt;
 &lt;div&gt;
   &lt;?php echo get_the_post_thumbnail($post-&gt;ID, 'post-thumbnail'); ?&gt;&quot;
 &lt;/div&gt;
&lt;?php endif;?&gt;
//Hiển thị title
&lt;h2 class=&quot;entry-title&quot;&gt;
  &lt;a href=&quot;&lt;?php the_permalink(); ?&gt;&quot;      title=&quot;&lt;?php printf( esc_attr__( 'Permalink to %s', 'twentyten' ), the_title_attribute( 'echo=0' ) ); ?&gt;&quot; rel=&quot;bookmark&quot;&gt;&lt;?php the_title(); ?&gt;
  &lt;/a&gt;
&lt;/h2&gt;
&lt;div&gt;
 &lt;?php echo get_the_term_list( $post-&gt;ID, 'Size', '&lt;strong&gt;Kích thước:&lt;/strong&gt;', ', ', '' );?&gt;
&lt;/div&gt;
&lt;div&gt;
 &lt;?php echo get_the_term_list( $post-&gt;ID, 'Brand', '&lt;strong&gt;Nhãn hiệu:&lt;/strong&gt;', ', ', '' );?&gt;
&lt;/div&gt;
&lt;div&gt;
  &lt;?php echo get_the_term_list($post-&gt;ID, 'Price', '&lt;strong&gt;Giá:&lt;/strong&gt;', '', '');?&gt;
&lt;/div&gt;
</pre>
<p><span class='post-span'>function get_the_term_list($id = 0, $taxonomy, $before = &#8221;, $sep = &#8221;, $after = &#8221;)</span>: hiện các taxonomy của bài viết này theo tên của taxonomy đã đăng ký.<br />
<strong>$id:</strong> $post-&gt;ID, id hiện tại của 1 post.<br />
<strong>$taxonomy:</strong> tên của taxonomy mình đã đăng ký, vd: Size, Price, Brand (lưu ý có phân biệt chữ hoa và thường).<br />
<strong>$before:</strong> thẻ, ký tự trước khi xuất ra tên của taxonomy, vd: &lt;strong&gt;Giá:&lt;/strong&gt;<br />
<strong>$sep:</strong> dấu các giữa các taxonomy, vd dấy phẩy (,).<br />
<strong>$after</strong>: thẻ, ký tự sau khi xuất ra tên của taxonomy, trong bài này mình để rỗng.</p>
<p>Giai đoạn cuối là post vài bài lên thử nghiệm và style css lại cho đẹp, trong demo này mình lấy theme 20 10 (twenty ten) mặc định cửa wp 3.0 và cũng không style lại cho giống shop thời trang lắm <img src='http://www.izwebz.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> .</p>
<h5>Kết luận</h5>
<p>Theo mình thì taxonomy thực sự rất hay, và rất cần thiết cho việc tùy chỉnh  wordpress làm việc theo ý mình. Mình đang có ý định viết 1 trang quản lý học sinh trên WP. Hy vọng sớm thành hiện thực. Tiện đây mình cũng xin giới thiệu luôn bài viết tiếp theo sẽ là Custom Post Type trong wp và sau nữa sẽ là một trang smallShop có sản phẩm, giỏ hàng và vài chi tiết khác. Nếu có thắc mắc hay đóng góp cải thiện thì mong các bạn comment ở bên dưới nha.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.izwebz.com/wordpress/wordprescustom-taxonomies/feed/</wfw:commentRss>
		<slash:comments>24</slash:comments>
		</item>
	</channel>
</rss>

