<?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>hieudt's blog &#187; sql</title>
	<atom:link href="http://hieudt.info/tag/sql/feed/" rel="self" type="application/rss+xml" />
	<link>http://hieudt.info</link>
	<description>WordPress and Symbian UIQ3</description>
	<lastBuildDate>Sat, 08 May 2010 01:05:46 +0000</lastBuildDate>
	<language>vi</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Đếm số lượng post/page trên blog WordPress của bạn</title>
		<link>http://hieudt.info/wp-tips/count-the-number-of-posts-on-your-wordpress-blog/</link>
		<comments>http://hieudt.info/wp-tips/count-the-number-of-posts-on-your-wordpress-blog/#comments</comments>
		<pubDate>Fri, 13 Mar 2009 07:31:05 +0000</pubDate>
		<dc:creator>hieudt</dc:creator>
				<category><![CDATA[WP Tips-Tricks]]></category>
		<category><![CDATA[comments]]></category>
		<category><![CDATA[sql]]></category>
		<category><![CDATA[tips]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://hieudt.info/?p=1155</guid>
		<description><![CDATA[Vừa rồi tôi đã hướng dẫn bạn cách đếm số comment, còn bây giờ tôi sẽ hướng dẫn đến cách đếm số post và page. Tương tự như comment nhưng post và page lại nằm ở table 'wp_posts' và có kèm theo vài điều kiện khác. Đoạn code dưới đây sẽ đếm số post: 1 [...]]]></description>
			<content:encoded><![CDATA[<p>Vừa rồi tôi đã hướng dẫn bạn <a href="http://hieudt.info/wp-tips/count-the-number-of-comments-on-your-wordpress-blog/">cách đếm số comment</a>, còn bây giờ tôi sẽ hướng dẫn đến cách đếm số post và page. Tương tự như comment nhưng post và page lại nằm ở table 'wp_posts' và có kèm theo vài điều kiện khác.</p>
<p>Đoạn code dưới đây sẽ đếm số post:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #000000; font-weight: bold;">global</span> <span style="color: #000088;">$wpdb</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$num_posts</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$wpdb</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">get_var</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;SELECT COUNT(ID) FROM <span style="color: #006699; font-weight: bold;">$wpdb-&gt;posts</span> WHERE post_type = 'post' AND post_status = 'publish' AND post_password = ''&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$num_posts</span> <span style="color: #339933;">&gt;</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #000088;">$num_posts</span> <span style="color: #339933;">=</span> <span style="color: #990000;">number_format</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$num_posts</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'Có tổng cộng '</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$num_posts</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">' bài viết trên blog của tôi'</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p>Các điều kiện đã dùng trong câu SQL trên là:</p>
<ul>
<li>post_type = 'post'</li>
<li>post_status = 'publish'</li>
<li>post_password = ''</li>
</ul>
<p>Để đếm số page, bạn chỉ việc thay 'post' thành 'page' ở chỗ post_type, còn nếu bạn muốn đếm luôn cả bài viết có đặt password thì bạn chỉ cần xóa đi điều kiện post_password = '' là xong. <img src='http://hieudt.info/blog/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> </p>
<p>Mặc dù hiện nay có khá nhiều plugin có chức năng tạo bảng thống kê trên blog của bạn nhưng nếu bạn chỉ đơn thuần muốn đếm số lượng post/page và comment thì tại sao bạn không tự tạo một bảng thống kê nho nhỏ cho riêng mình chỉ với vài dòng code đơn giản? Những blog chia sẻ software hay ebook mà đặt đoạn code trên ở sidebar thì tuyệt vời.  >:d< </p>

	Tags: <a href="http://hieudt.info/tag/comments/" title="comments" rel="tag">comments</a>, <a href="http://hieudt.info/tag/sql/" title="sql" rel="tag">sql</a>, <a href="http://hieudt.info/tag/tips/" title="tips" rel="tag">tips</a>, <a href="http://hieudt.info/tag/wordpress/" title="wordpress" rel="tag">wordpress</a><br />

	<h2>You may also like...</h2>
	<ul class="st-related-posts">
	<li><a href="http://hieudt.info/wp-tips/count-the-number-of-comments-on-your-wordpress-blog/" title="Đếm số lượng comment trên blog WordPress của bạn (March 12, 2009)">Đếm số lượng comment trên blog WordPress của bạn</a></li>
	<li><a href="http://hieudt.info/wp-tips/display-the-number-of-sql-queries-on-your-blog/" title="Hiện số câu SQL được truy vấn trên blog của bạn (December 23, 2008)">Hiện số câu SQL được truy vấn trên blog của bạn</a></li>
	<li><a href="http://hieudt.info/wp-tips/let-google-analytics-exclude-your-own-visits/" title="WP Tip: Let Google Analytics exclude your own visits (December 4, 2008)">WP Tip: Let Google Analytics exclude your own visits</a></li>
	<li><a href="http://hieudt.info/wp-tips/wp-tip-exclude-pages-from-search-results/" title="WP Tip &#8211; Exclude pages from search results (December 2, 2008)">WP Tip &#8211; Exclude pages from search results</a></li>
	<li><a href="http://hieudt.info/wp-plugins/moderate-your-wordpress-comments-from-your-desktop/" title="WP Plugin: Moderate your WordPress comments from your Desktop (December 2, 2008)">WP Plugin: Moderate your WordPress comments from your Desktop</a></li>
	<li><a href="http://hieudt.info/wp-plugins/comment-info-detector/" title="WP Plugin: Comment Info Detector (December 15, 2008)">WP Plugin: Comment Info Detector</a></li>
	<li><a href="http://hieudt.info/wp-tips/wordpress-27-theme-admin-area-tips-and-tricks/" title="Để theme của bạn hoạt động tốt với WordPress 2.7 (December 20, 2008)">Để theme của bạn hoạt động tốt với WordPress 2.7</a></li>
	<li><a href="http://hieudt.info/wp-tutorial/understanding-revisions-in-wordpress-from-a-to-z/" title="Tìm hiểu về Revision trong WordPress từ A tới Z (March 4, 2009)">Tìm hiểu về Revision trong WordPress từ A tới Z</a></li>
	<li><a href="http://hieudt.info/wp-plugins/some-plugins-for-smilies-in-wordpress-part-1/" title="Những plugin về Smilies cho WordPress &#8211; Phần 1 (April 5, 2009)">Những plugin về Smilies cho WordPress &#8211; Phần 1</a></li>
	<li><a href="http://hieudt.info/wp-plugins/four-plugins-can-move-comments-in-wordpress/" title="Bốn plugin giúp di chuyển comment trong WordPress (April 10, 2009)">Bốn plugin giúp di chuyển comment trong WordPress</a></li>
</ul>

]]></content:encoded>
			<wfw:commentRss>http://hieudt.info/wp-tips/count-the-number-of-posts-on-your-wordpress-blog/feed/</wfw:commentRss>
		<slash:comments>16</slash:comments>
		</item>
		<item>
		<title>Đếm số lượng comment trên blog WordPress của bạn</title>
		<link>http://hieudt.info/wp-tips/count-the-number-of-comments-on-your-wordpress-blog/</link>
		<comments>http://hieudt.info/wp-tips/count-the-number-of-comments-on-your-wordpress-blog/#comments</comments>
		<pubDate>Thu, 12 Mar 2009 11:12:32 +0000</pubDate>
		<dc:creator>hieudt</dc:creator>
				<category><![CDATA[WP Tips-Tricks]]></category>
		<category><![CDATA[comments]]></category>
		<category><![CDATA[sql]]></category>
		<category><![CDATA[tips]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://hieudt.info/?p=1153</guid>
		<description><![CDATA[Bài viết này sẽ hướng dẫn bạn cách hiển thị số lượng comment hiện đang có trên blog của bạn (tất nhiên là các comment hợp lệ đã được approved) bằng một đoạn code php khá đơn giản dưới đây. 1 2 3 4 5 6 &#60;?php global $wpdb; $num_comments = $wpdb-&#62;get_var&#40;&#34;SELECT COUNT(comment_ID) FROM $wpdb-&#62;comments [...]]]></description>
			<content:encoded><![CDATA[<p>Bài viết này sẽ hướng dẫn bạn cách hiển thị số lượng comment hiện đang có trên blog của bạn (tất nhiên là các comment hợp lệ đã được approved) bằng một đoạn code php khá đơn giản dưới đây.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #000000; font-weight: bold;">global</span> <span style="color: #000088;">$wpdb</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$num_comments</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$wpdb</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">get_var</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;SELECT COUNT(comment_ID) FROM <span style="color: #006699; font-weight: bold;">$wpdb-&gt;comments</span> WHERE comment_approved = '1'&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$num_comments</span> <span style="color: #339933;">&gt;</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #000088;">$num_comments</span> <span style="color: #339933;">=</span> <span style="color: #990000;">number_format</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$num_comments</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;Có tổng cộng &quot;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$num_comments</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot; comment trên blog của tôi&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p>Dán đoạn code trên vào chỗ bạn thích trong các file php của theme mà bạn đang sử dụng. Còn đây là live demo <img src='http://hieudt.info/blog/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> </p>
<p><span class="highlight">Có tổng cộng 1,131 comment trên blog của tôi</span></p>
<p>Rất đơn giản phải không nào? Kỳ tới tôi sẽ tiếp tục hướng dẫn bạn cách đếm số lượng các post và page. Nhớ theo dõi nhé! <img src='http://hieudt.info/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>

	Tags: <a href="http://hieudt.info/tag/comments/" title="comments" rel="tag">comments</a>, <a href="http://hieudt.info/tag/sql/" title="sql" rel="tag">sql</a>, <a href="http://hieudt.info/tag/tips/" title="tips" rel="tag">tips</a>, <a href="http://hieudt.info/tag/wordpress/" title="wordpress" rel="tag">wordpress</a><br />

	<h2>You may also like...</h2>
	<ul class="st-related-posts">
	<li><a href="http://hieudt.info/wp-tips/count-the-number-of-posts-on-your-wordpress-blog/" title="Đếm số lượng post/page trên blog WordPress của bạn (March 13, 2009)">Đếm số lượng post/page trên blog WordPress của bạn</a></li>
	<li><a href="http://hieudt.info/wp-tips/display-the-number-of-sql-queries-on-your-blog/" title="Hiện số câu SQL được truy vấn trên blog của bạn (December 23, 2008)">Hiện số câu SQL được truy vấn trên blog của bạn</a></li>
	<li><a href="http://hieudt.info/wp-tips/let-google-analytics-exclude-your-own-visits/" title="WP Tip: Let Google Analytics exclude your own visits (December 4, 2008)">WP Tip: Let Google Analytics exclude your own visits</a></li>
	<li><a href="http://hieudt.info/wp-tips/wp-tip-exclude-pages-from-search-results/" title="WP Tip &#8211; Exclude pages from search results (December 2, 2008)">WP Tip &#8211; Exclude pages from search results</a></li>
	<li><a href="http://hieudt.info/wp-plugins/moderate-your-wordpress-comments-from-your-desktop/" title="WP Plugin: Moderate your WordPress comments from your Desktop (December 2, 2008)">WP Plugin: Moderate your WordPress comments from your Desktop</a></li>
	<li><a href="http://hieudt.info/wp-plugins/comment-info-detector/" title="WP Plugin: Comment Info Detector (December 15, 2008)">WP Plugin: Comment Info Detector</a></li>
	<li><a href="http://hieudt.info/wp-tips/wordpress-27-theme-admin-area-tips-and-tricks/" title="Để theme của bạn hoạt động tốt với WordPress 2.7 (December 20, 2008)">Để theme của bạn hoạt động tốt với WordPress 2.7</a></li>
	<li><a href="http://hieudt.info/wp-tutorial/understanding-revisions-in-wordpress-from-a-to-z/" title="Tìm hiểu về Revision trong WordPress từ A tới Z (March 4, 2009)">Tìm hiểu về Revision trong WordPress từ A tới Z</a></li>
	<li><a href="http://hieudt.info/wp-plugins/some-plugins-for-smilies-in-wordpress-part-1/" title="Những plugin về Smilies cho WordPress &#8211; Phần 1 (April 5, 2009)">Những plugin về Smilies cho WordPress &#8211; Phần 1</a></li>
	<li><a href="http://hieudt.info/wp-plugins/four-plugins-can-move-comments-in-wordpress/" title="Bốn plugin giúp di chuyển comment trong WordPress (April 10, 2009)">Bốn plugin giúp di chuyển comment trong WordPress</a></li>
</ul>

]]></content:encoded>
			<wfw:commentRss>http://hieudt.info/wp-tips/count-the-number-of-comments-on-your-wordpress-blog/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>Tìm hiểu về Revision trong WordPress từ A tới Z</title>
		<link>http://hieudt.info/wp-tutorial/understanding-revisions-in-wordpress-from-a-to-z/</link>
		<comments>http://hieudt.info/wp-tutorial/understanding-revisions-in-wordpress-from-a-to-z/#comments</comments>
		<pubDate>Wed, 04 Mar 2009 15:26:55 +0000</pubDate>
		<dc:creator>hieudt</dc:creator>
				<category><![CDATA[WP Tutorial]]></category>
		<category><![CDATA[plugins]]></category>
		<category><![CDATA[sql]]></category>
		<category><![CDATA[tutorial]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://hieudt.info/?p=1142</guid>
		<description><![CDATA[Là người dùng WordPress, có bao giờ bạn nghe nói đến tính năng Revision (có từ WordPress 2.6) chưa? Có thể bạn đã nghe qua ở đâu đó nhưng chưa thật sự hiểu rõ hoặc bạn không muốn tìm hiểu thì tôi khuyên bạn nên đọc bài viết này để hiểu rõ hơn bởi nó [...]]]></description>
			<content:encoded><![CDATA[<p>Là người dùng WordPress, có bao giờ bạn nghe nói đến tính năng Revision (có từ WordPress 2.6) chưa? Có thể bạn đã nghe qua ở đâu đó nhưng chưa thật sự hiểu rõ hoặc bạn không muốn tìm hiểu thì tôi khuyên bạn nên đọc bài viết này để hiểu rõ hơn bởi nó có ảnh hưởng đến database của blog mà bạn đang chạy.</p>
<p>Bản thân tôi trước đây cũng không quan tâm đến chuyện này, bởi dù có quan tâm hay không thì blog của mình vẫn chạy bình thường, đâu có bị trục trặc gì mà phải vọc phá chi cho tốn thời gian. <img src='http://hieudt.info/blog/wp-includes/images/smilies/icon_mrgreen.gif' alt=':mrgreen:' class='wp-smiley' /> </p>
<p>Nhưng tình cờ một hôm tôi vào phpMyAdmin để backup database cho blog thì tôi phát hiện ra rằng: có rất nhiều bài viết cùng 'post_title', 'post_content', 'post_author' nhưng lại khác 'ID', 'post_date' và 'post_type' trong table 'wp_posts'. Chỉ cần dùng một câu lệnh SQL đơn giản dưới đây là bạn sẽ thấy được ngay: (nhớ thay chữ 'Hello World!' bằng tên một bài viết nào đó trên blog của bạn)</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code"><pre class="sql" style="font-family:monospace;"><span style="color: #993333; font-weight: bold;">SELECT</span> ID<span style="color: #66cc66;">,</span> post_title<span style="color: #66cc66;">,</span> post_author<span style="color: #66cc66;">,</span> post_content<span style="color: #66cc66;">,</span> post_date<span style="color: #66cc66;">,</span> post_type
<span style="color: #993333; font-weight: bold;">FROM</span> wp_posts
<span style="color: #993333; font-weight: bold;">WHERE</span> post_title <span style="color: #66cc66;">=</span> <span style="color: #ff0000;">'Hello World!'</span></pre></td></tr></table></div>

<p><img src="http://hieudt.info/media/2009/03/sql.png" alt="sql" width="607" height="157" class="aligncenter size-full wp-image-1150" /><br />
Xem qua một loạt các bài viết như vậy, tôi mới nhận thấy rằng: trong số những bài trùng lặp ấy, chỉ có một bài duy nhất có 'post_type' là 'post' (hoặc 'page' nếu đó là trang) là bài viết đang được publish, còn lại là attachment và <strong>revision</strong> &lt;= cái mà chúng ta đang nói đến.</p>
<p>Vậy revision là gì và tại sao WordPress lại tạo ra chúng? Câu trả lời sẽ được giải đáp ở trang 2 của bài viết này.</p>

	Tags: <a href="http://hieudt.info/tag/plugins/" title="plugins" rel="tag">plugins</a>, <a href="http://hieudt.info/tag/sql/" title="sql" rel="tag">sql</a>, <a href="http://hieudt.info/tag/tutorial/" title="tutorial" rel="tag">tutorial</a>, <a href="http://hieudt.info/tag/wordpress/" title="wordpress" rel="tag">wordpress</a><br />

	<h2>You may also like...</h2>
	<ul class="st-related-posts">
	<li><a href="http://hieudt.info/wp-plugins/some-plugins-for-smilies-in-wordpress-part-1/" title="Những plugin về Smilies cho WordPress &#8211; Phần 1 (April 5, 2009)">Những plugin về Smilies cho WordPress &#8211; Phần 1</a></li>
	<li><a href="http://hieudt.info/wp-plugins/wp-lytebox-plugin/" title="WP-Lytebox Plugin (December 3, 2008)">WP-Lytebox Plugin</a></li>
	<li><a href="http://hieudt.info/wp-plugins/subscribe2-411/" title="WP Plugin: Subscribe2 4.11 (November 27, 2008)">WP Plugin: Subscribe2 4.11</a></li>
	<li><a href="http://hieudt.info/wp-plugins/send-mails-with-themes-and-templates/" title="WP Plugin: Send Mails with Themes and Templates (November 28, 2008)">WP Plugin: Send Mails with Themes and Templates</a></li>
	<li><a href="http://hieudt.info/wp-plugins/search-everything/" title="WP Plugin: Search Everything (November 27, 2008)">WP Plugin: Search Everything</a></li>
	<li><a href="http://hieudt.info/wp-plugins/moderate-your-wordpress-comments-from-your-desktop/" title="WP Plugin: Moderate your WordPress comments from your Desktop (December 2, 2008)">WP Plugin: Moderate your WordPress comments from your Desktop</a></li>
	<li><a href="http://hieudt.info/wp-plugins/comment-info-detector/" title="WP Plugin: Comment Info Detector (December 15, 2008)">WP Plugin: Comment Info Detector</a></li>
	<li><a href="http://hieudt.info/wp-plugins/auto-hyperlink-urls/" title="WP Plugin: Auto-hyperlink URLs (December 3, 2008)">WP Plugin: Auto-hyperlink URLs</a></li>
	<li><a href="http://hieudt.info/wp-plugins/wordpress-plugin-releases-for-1128/" title="WordPress Plugin Releases for 11/28 (November 28, 2008)">WordPress Plugin Releases for 11/28</a></li>
	<li><a href="http://hieudt.info/wp-plugins/social-bookmarking-plugins-for-wordpress/" title="Social Bookmarking Plugins for WordPress (November 25, 2008)">Social Bookmarking Plugins for WordPress</a></li>
</ul>

]]></content:encoded>
			<wfw:commentRss>http://hieudt.info/wp-tutorial/understanding-revisions-in-wordpress-from-a-to-z/feed/</wfw:commentRss>
		<slash:comments>20</slash:comments>
		</item>
		<item>
		<title>Hiện số câu SQL được truy vấn trên blog của bạn</title>
		<link>http://hieudt.info/wp-tips/display-the-number-of-sql-queries-on-your-blog/</link>
		<comments>http://hieudt.info/wp-tips/display-the-number-of-sql-queries-on-your-blog/#comments</comments>
		<pubDate>Tue, 23 Dec 2008 13:42:13 +0000</pubDate>
		<dc:creator>hieudt</dc:creator>
				<category><![CDATA[WP Tips-Tricks]]></category>
		<category><![CDATA[sql]]></category>
		<category><![CDATA[tips]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://hieudt.info/?p=651</guid>
		<description><![CDATA[Bạn muốn hiển thị số lượng các câu truy vấn SQL đã tác động lên cơ sở dữ liệu trên blog của bạn như tôi đã thực hiện trên blog này giống như thế này: 78 câu truy vấn trong 1.621 giây Rất đơn giản, chỉ cần mở file footer.php trong thư mục chứa theme [...]]]></description>
			<content:encoded><![CDATA[<p>Bạn muốn hiển thị số lượng các câu truy vấn SQL đã tác động lên cơ sở dữ liệu trên blog của bạn <span style="text-decoration: line-through;">như tôi đã thực hiện trên blog này</span> giống như thế này:</p>
<div class="box">
<div class="content">
86 câu truy vấn trong 1.827 giây</div>
</div>
<p>Rất đơn giản, chỉ cần mở file <strong>footer.php</strong> trong thư mục chứa theme mà bạn đang dùng rồi dán đoạn code sau tại bất cứ nơi nào bạn thích:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> get_num_queries<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span> câu truy vấn trong <span style="color: #000000; font-weight: bold;">&lt;?php</span> timer_stop<span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span> giây</pre></td></tr></table></div>

<p>Nếu bạn muốn chỉ những user đã đăng nhập mới thấy được số câu truy vấn thì dùng đoạn code sau:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>is_user_logged_in<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> get_num_queries<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span> câu truy vấn trong <span style="color: #000000; font-weight: bold;">&lt;?php</span> timer_stop<span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span> giây.
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p>Cám ơn <em><a href="http://" target="_blank">Jean-Baptiste Jung</a> </em>đã nghĩ ra ý tưởng này.</p>

	Tags: <a href="http://hieudt.info/tag/sql/" title="sql" rel="tag">sql</a>, <a href="http://hieudt.info/tag/tips/" title="tips" rel="tag">tips</a>, <a href="http://hieudt.info/tag/wordpress/" title="wordpress" rel="tag">wordpress</a><br />

	<h2>You may also like...</h2>
	<ul class="st-related-posts">
	<li><a href="http://hieudt.info/wp-tips/count-the-number-of-posts-on-your-wordpress-blog/" title="Đếm số lượng post/page trên blog WordPress của bạn (March 13, 2009)">Đếm số lượng post/page trên blog WordPress của bạn</a></li>
	<li><a href="http://hieudt.info/wp-tips/count-the-number-of-comments-on-your-wordpress-blog/" title="Đếm số lượng comment trên blog WordPress của bạn (March 12, 2009)">Đếm số lượng comment trên blog WordPress của bạn</a></li>
	<li><a href="http://hieudt.info/wp-tips/let-google-analytics-exclude-your-own-visits/" title="WP Tip: Let Google Analytics exclude your own visits (December 4, 2008)">WP Tip: Let Google Analytics exclude your own visits</a></li>
	<li><a href="http://hieudt.info/wp-tips/wp-tip-exclude-pages-from-search-results/" title="WP Tip &#8211; Exclude pages from search results (December 2, 2008)">WP Tip &#8211; Exclude pages from search results</a></li>
	<li><a href="http://hieudt.info/wp-tips/wordpress-27-theme-admin-area-tips-and-tricks/" title="Để theme của bạn hoạt động tốt với WordPress 2.7 (December 20, 2008)">Để theme của bạn hoạt động tốt với WordPress 2.7</a></li>
	<li><a href="http://hieudt.info/wp-tutorial/understanding-revisions-in-wordpress-from-a-to-z/" title="Tìm hiểu về Revision trong WordPress từ A tới Z (March 4, 2009)">Tìm hiểu về Revision trong WordPress từ A tới Z</a></li>
	<li><a href="http://hieudt.info/wp-tips/adding-custom-links-to-wordpress-page-menu/" title="Chèn link riêng vào menu Page của WordPress (March 23, 2009)">Chèn link riêng vào menu Page của WordPress</a></li>
	<li><a href="http://hieudt.info/wp-plugins/wp-lytebox-plugin/" title="WP-Lytebox Plugin (December 3, 2008)">WP-Lytebox Plugin</a></li>
	<li><a href="http://hieudt.info/wp-themes/versatility-2-column-ad-ready-and-widgetized/" title="WP Theme: Versatility 2 Column, Ad-Ready and Widgetized (December 13, 2008)">WP Theme: Versatility 2 Column, Ad-Ready and Widgetized</a></li>
	<li><a href="http://hieudt.info/wp-plugins/wptouch-formats-wordpress-into-iphone-theme/" title="WP Plugin: WPtouch Formats WordPress into iPhone Theme (November 27, 2008)">WP Plugin: WPtouch Formats WordPress into iPhone Theme</a></li>
</ul>

]]></content:encoded>
			<wfw:commentRss>http://hieudt.info/wp-tips/display-the-number-of-sql-queries-on-your-blog/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>
