<?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; tips</title>
	<atom:link href="http://hieudt.info/tag/tips/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.2.1</generator>
		<item>
		<title>Chèn link riêng vào menu Page của WordPress</title>
		<link>http://hieudt.info/wp-tips/adding-custom-links-to-wordpress-page-menu/</link>
		<comments>http://hieudt.info/wp-tips/adding-custom-links-to-wordpress-page-menu/#comments</comments>
		<pubDate>Mon, 23 Mar 2009 08:01:53 +0000</pubDate>
		<dc:creator>hieudt</dc:creator>
				<category><![CDATA[WP Tips-Tricks]]></category>
		<category><![CDATA[filter]]></category>
		<category><![CDATA[tips]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://hieudt.info/?p=1160</guid>
		<description><![CDATA[Trước đây có một số bạn hỏi tôi cách chèn thêm link riêng (ví dụ như link đến forum) vào menu Page của WordPress thì làm thế nào bởi WordPress không hỗ trợ chúng ta làm việc đó trong WP-Admin. Tất nhiên là nếu chịu khó suy nghĩ thì ta vẫn có thể tìm ra [...]]]></description>
			<content:encoded><![CDATA[<p>Trước đây có một số bạn hỏi tôi cách chèn thêm link riêng (ví dụ như link đến forum) vào menu Page của WordPress thì làm thế nào bởi WordPress không hỗ trợ chúng ta làm việc đó trong WP-Admin. Tất nhiên là nếu chịu khó suy nghĩ thì ta vẫn có thể tìm ra cách bởi các menu ấy chẳng qua là code HTML được hàm wp_list_pages() của WordPress xuất ra dựa trên danh sách các Page hiện có trong blog của bạn.</p>
<p>Cách đơn giản nhất để làm chuyện này là mở file header.php của theme mà bạn đang dùng sau đó thêm code HTML vào bên dưới hàm wp_list_pages().<br />
<img src="http://hieudt.info/media/2009/03/customlinks.png" alt="chèn link ngoài vào menu page" width="607" height="74" class="alignleft size-full wp-image-1161" /></p>
<p>Cách thứ hai là bạn dùng một hàm php để "thọc" vào kết quả trả về của hàm wp_list_pages() bằng cách chèn đoạn code dưới đây vào file functions.php</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;">function</span> add_custom_links<span style="color: #009900;">&#40;</span><span style="color: #000088;">$output</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000088;">$output</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">'&lt;li&gt;&lt;a href=&quot;http://hieudt.info/forum/&quot;&gt;Forum&lt;/a&gt;&lt;/li&gt;'</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$output</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">'&lt;li&gt;&lt;a href=&quot;http://twitter.com/hieudt/&quot;&gt;My Twitter&lt;/a&gt;&lt;/li&gt;'</span><span style="color: #339933;">;</span>
        <span style="color: #b1b100;">return</span> <span style="color: #000088;">$output</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
add_filter<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'wp_list_pages'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'add_custom_links'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p><strong>Một số lưu ý:</strong><br />
1) Nếu không thích chèn code vào theme thì bạn có thể chèn vào plugin nào đó cũng được nhưng bắt buộc phải đặt code vào giữa khối <span class="highlight">&lt;?php ... ?&gt;</span>.<br />
2) Ví dụ ở trên chỉ dùng để minh họa, khi sử dụng bạn nên sửa lại theo ý riêng của mình.</p>
<p>Hy vọng bài viết này sẽ giúp ích cho nhiều bạn. Nếu bạn còn có cách nào khác hoặc biết plugin làm được chuyện này thì hoan nghênh bạn chia sẻ với mọi ngườ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/filter/" title="filter" rel="tag">filter</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 />
]]></content:encoded>
			<wfw:commentRss>http://hieudt.info/wp-tips/adding-custom-links-to-wordpress-page-menu/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<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 />
]]></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,226 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 />
]]></content:encoded>
			<wfw:commentRss>http://hieudt.info/wp-tips/count-the-number-of-comments-on-your-wordpress-blog/feed/</wfw:commentRss>
		<slash:comments>11</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: 49 câu truy vấn trong 1.366 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">
50 câu truy vấn trong 1.716 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 />
]]></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>
		<item>
		<title>Để theme của bạn hoạt động tốt với WordPress 2.7</title>
		<link>http://hieudt.info/wp-tips/wordpress-27-theme-admin-area-tips-and-tricks/</link>
		<comments>http://hieudt.info/wp-tips/wordpress-27-theme-admin-area-tips-and-tricks/#comments</comments>
		<pubDate>Sat, 20 Dec 2008 13:44:24 +0000</pubDate>
		<dc:creator>hieudt</dc:creator>
				<category><![CDATA[WP Tips-Tricks]]></category>
		<category><![CDATA[theme hack]]></category>
		<category><![CDATA[tips]]></category>
		<category><![CDATA[tutorial]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://hieudt.info/?p=631</guid>
		<description><![CDATA[WordPress 2.7 được phát hành cách đây vài ngày với nhiều tính năng mới lạ và hấp dẫn, hứa hẹn sẽ là một blog platform mạnh mẽ, giúp cho việc viết - quản lý blog của bạn trở nên dễ dàng hơn bao giờ hết. Sau khi nâng cấp lên WordPress 2.7, do có sự [...]]]></description>
			<content:encoded><![CDATA[<div id="attachment_633" class="wp-caption alignright" style="width: 310px"><a href="http://hieudt.info/media/2008/12/wp27-10.gif"><img class="size-medium wp-image-633" src="http://hieudt.info/media/2008/12/wp27-10-300x125.gif" alt="Enhanced Comment Display" width="300" height="125" /></a><p class="wp-caption-text">Enhanced Comment Display</p></div>
<p>WordPress 2.7 được phát hành cách đây vài ngày với nhiều tính năng mới lạ và hấp dẫn, hứa hẹn sẽ là một blog platform mạnh mẽ, giúp cho việc viết - quản lý blog của bạn trở nên dễ dàng hơn bao giờ hết.</p>
<p>Sau khi nâng cấp lên WordPress 2.7, do có sự thay đổi về mã nguồn nên có thể những theme bạn đang sử dụng không còn tương thích nữa. Tuy nhiên, bạn vẫn có thể làm cho chúng chạy lại bình thường bằng việc chỉnh sửa một số file trong theme.</p>
<p>Noupe có đăng một bài viết tên là “<a title="Mastering Your WordPress 2.7 Theme &amp; Admin Area" href="http://www.noupe.com/wordpress/mastering-your-wordpress-27-theme-admin-area-tips-and-tricks.html" target="_blank">Mastering Your WordPress 2.7 Theme &amp; Admin Area: Tips and Tricks</a>“ nói về những mẹo vặt/thủ thuật để bạn sửa lại theme cho tương thích với WordPress 2.7.</p>
<p>Nếu bạn có kinh nghiệm về việc chỉnh sửa theme để theme chạy tốt với WordPress 2.7 thì hãy chia sẻ với mọi ngườ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/theme-hack/" title="theme hack" rel="tag">theme hack</a>, <a href="http://hieudt.info/tag/tips/" title="tips" rel="tag">tips</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 />
]]></content:encoded>
			<wfw:commentRss>http://hieudt.info/wp-tips/wordpress-27-theme-admin-area-tips-and-tricks/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>WP Tip: Let Google Analytics exclude your own visits</title>
		<link>http://hieudt.info/wp-tips/let-google-analytics-exclude-your-own-visits/</link>
		<comments>http://hieudt.info/wp-tips/let-google-analytics-exclude-your-own-visits/#comments</comments>
		<pubDate>Thu, 04 Dec 2008 03:30:40 +0000</pubDate>
		<dc:creator>hieudt</dc:creator>
				<category><![CDATA[WP Tips-Tricks]]></category>
		<category><![CDATA[google]]></category>
		<category><![CDATA[tips]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://hieudt.info/?p=473</guid>
		<description><![CDATA[After reading the article “Exclude your own visits in Google Analytics for WordPress blogs” on JohnTP.com, I think that is very useful trick to exclude your own visits in Google Analytics when you access your WordPress blogs, using the code bellow to do that: &#60;?php if &#40;!$user_ID&#41; &#123; ?&#62; your Google Analytics code here &#60;?php [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignright size-full wp-image-486" src="http://hieudt.info/media/2008/12/google-analytics.gif" alt="" width="184" height="47" />After reading the article “<a rel="nofollow" href="http://www.johntp.com/2008/08/08/exclude-your-visits-in-google-analytics/" target="_blank">Exclude your own visits in Google Analytics for WordPress blogs</a>” on <a href="http://www.johntp.com/" target="_blank">JohnTP.com</a>,<br />
I think that is very useful trick to exclude your own visits in Google Analytics when you access your WordPress blogs, using the code bellow to do that:</p>

<div class="wp_syntax"><div 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><span style="color: #339933;">!</span><span style="color: #000088;">$user_ID</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span> your Google Analytics code here <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></div></div>

<p>But the code is not pretty well for blogs with enabled user registration because using <strong>$user_ID</strong> variable will exclude all visitors who has already been a member. You know that we are going to exclude tracking for only the administrator whose username is "admin" and level is 10 so that we need to have a better condition to detect which type of currently logged in user. I have an improvement for the code here, place it to your footer.php :</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
</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;">$current_user</span><span style="color: #339933;">;</span> get_currentuserinfo<span style="color: #009900;">&#40;</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;">$current_user</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">user_level</span> <span style="color: #339933;">!=</span> <span style="color: #cc66cc;">10</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #000088;">$current_user</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">user_login</span> <span style="color: #339933;">!=</span> <span style="color: #0000ff;">'admin'</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
your Google Analytics code here
<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>This code is currently working well on my blog. I hope it will help you to exclude your own visits in Google Analytics exactly!</p>
<p>PS: Note that you can use any web statistics code you like (statcounter for example), not just for Google Analytics.</p>

	Tags: <a href="http://hieudt.info/tag/google/" title="google" rel="tag">google</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 />
]]></content:encoded>
			<wfw:commentRss>http://hieudt.info/wp-tips/let-google-analytics-exclude-your-own-visits/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>WP Tip &#8211; Exclude pages from search results</title>
		<link>http://hieudt.info/wp-tips/wp-tip-exclude-pages-from-search-results/</link>
		<comments>http://hieudt.info/wp-tips/wp-tip-exclude-pages-from-search-results/#comments</comments>
		<pubDate>Tue, 02 Dec 2008 06:32:49 +0000</pubDate>
		<dc:creator>hieudt</dc:creator>
				<category><![CDATA[WP Tips-Tricks]]></category>
		<category><![CDATA[filter]]></category>
		<category><![CDATA[tips]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://hieudt.info/?p=384</guid>
		<description><![CDATA[If you intend to exclude pages from search results, you can use the Simply-Exclude plugin. However, another solution that works pretty well is to add a filter in functions.php to only include posts categories instead of excluding pages from search results: 1 2 3 4 5 6 7 function mySearchPostsFilter&#40;$query&#41; &#123; if &#40;$query-&#62;is_search&#40;&#41;&#41; &#123; $query-&#62;set&#40;'cat','12,14,16,17,18'&#41;; [...]]]></description>
			<content:encoded><![CDATA[<p>If you intend to exclude pages from search results, you can use the <a href="http://www.codehooligans.com/2008/04/27/simply-exclude-plugin/" target="_blank">Simply-Exclude plugin</a>. However, another solution that works pretty well is to add a filter in <strong>functions.php</strong> to only include posts categories instead of excluding pages from search results:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> mySearchPostsFilter<span style="color: #009900;">&#40;</span><span style="color: #000088;">$query</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$query</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">is_search</span><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: #000088;">$query</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">set</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'cat'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'12,14,16,17,18'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// your category IDs</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #b1b100;">return</span> <span style="color: #000088;">$query</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
add_filter<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'pre_get_posts'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'mySearchPostsFilter'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>Just replace the posts category IDs (’12,14,16,17,18′) by your owns and it should work. That’s all!</p>

	Tags: <a href="http://hieudt.info/tag/filter/" title="filter" rel="tag">filter</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 />
]]></content:encoded>
			<wfw:commentRss>http://hieudt.info/wp-tips/wp-tip-exclude-pages-from-search-results/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

