<?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>ZENVERSE &#187; wordpress</title>
	<atom:link href="http://zenverse.net/tag/wordpress/feed/" rel="self" type="application/rss+xml" />
	<link>http://zenverse.net</link>
	<description>Design and Web Development</description>
	<lastBuildDate>Tue, 31 Jan 2012 02:46:21 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>[WordPress] How to Exclude Certain Categories From RSS Feed, Home, Search Page and More</title>
		<link>http://zenverse.net/wordpress-exclude-categories/</link>
		<comments>http://zenverse.net/wordpress-exclude-categories/#comments</comments>
		<pubDate>Thu, 15 Dec 2011 06:49:35 +0000</pubDate>
		<dc:creator>Zen</dc:creator>
				<category><![CDATA[Wordpress Development]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://zenverse.net/?p=2375</guid>
		<description><![CDATA[Sometimes we need to exclude a few unimportant categories from our main feed or other pages. A quick search through the web, you will arrive at wprecipes' tutorial, which unfortunately happens to be erroneous because wrong function was used (as of 15 Dec 2011). Anyway, in this blogpost I am gonna show how to exclude categories in RSS Feed, as well as Homepage, Search Page and more.

There are a number of ways to achieve what we want, but the best and cleanest method is to exclude using WordPress Action Hook.]]></description>
			<content:encoded><![CDATA[<p>Sometimes we need to exclude a few unimportant categories from our main feed or other wordpress pages. A quick search through the web, you will arrive at wprecipes&#8217; tutorial, which unfortunately happens to be erroneous because wrong function was used (as of 15 Dec 2011). Anyway, in this blogpost I am gonna show how to exclude categories in RSS Feed, as well as Homepage, Search Page and more.</p>
<p>There are a number of ways to achieve what we want, but the best and cleanest method is to exclude using WordPress Action Hook: <a href="http://codex.wordpress.org/Plugin_API/Action_Reference/pre_get_posts" target="_blank">pre_get_posts</a>. Using this action hook, we can easily exclude any categories in all wordpress generated pages.</p>
<h3>Exclude Certain Categories from RSS Feed</h3>
<p>First thing you need to do is find the category IDs that you want to hide. WPrecipes <a href="http://www.wprecipes.com/how-to-find-wordpress-category-id" target="_blank">explains this</a> pretty well.</p>
<p>Let&#8217;s say you want to exclude category 3, 4 and 5. Open your theme&#8217;s functions.php, paste these codes:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p2375code1'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p23751"><td class="code" id="p2375code1"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> mytheme_exclude_cats<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_feed</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;">'-3,-4,-5'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #666666; font-style: italic;">//seperate by comma</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>
&nbsp;
add_action<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'pre_get_posts'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'mytheme_exclude_cats'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<ul>
<li><strong><u>pre_get_posts</u></strong> is an action hook that is triggered everytime before wordpress actually retrieve post from database. Therefore, we can tell wordpress to exclude certain categories.</li>
<li><strong><u>$query</u></strong> is a wordpress query object that carries information about current query: how many post to show, what categories to show to exclude, at which page does this query runs, etc.<br />
If you are familiar with writing custom query using WP_Query(), $query is actually the parameters of <a href="http://codex.wordpress.org/Class_Reference/WP_Query#Interacting_with_WP_Query" target="_blank">WP_Query</a>.</li>
<li><strong><u>$query->is_feed</u></strong> carries boolean value of TRUE only when you are in Feed Page.</li>
</ul>
<p>You can run var_dump($query) inside the function to learn more about what the object holds.</p>
<h3>Exclude Certain Categories from Homepage</h3>
<p>Just simply change &#8220;is_feed&#8221; to &#8220;is_home&#8221;:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p2375code2'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p23752"><td class="code" id="p2375code2"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> mytheme_exclude_cats<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_home</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;">'-3,-4,-5'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #666666; font-style: italic;">//seperate by comma</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>
&nbsp;
add_action<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'pre_get_posts'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'mytheme_exclude_cats'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<h3>Exclude from other places</h3>
<p>Just simply change &#8220;is_feed&#8221; to the following:</p>
<p>is_feed &#8211; in RSS feed page<br />
is_home &#8211; in blog homepage<br />
is_category &#8211; in category page<br />
is_tag &#8211; in tag page<br />
is_search &#8211; in search page<br />
is_comment_feed &#8211; in comment RSS feed page<br />
is_author &#8211; in author archive page</p>
<h3>Exclude Specific Categories from more than 1 pages</h3>
<p>For example, to exclude category 3, 4 and 5 in both RSS Feed and Search page, it will be just as easy as:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p2375code3'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p23753"><td class="code" id="p2375code3"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> mytheme_exclude_cats<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: #339933;">||</span> <span style="color: #000088;">$query</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">is_feed</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;">'-3,-4,-5'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #666666; font-style: italic;">//seperate by comma</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>
&nbsp;
add_action<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'pre_get_posts'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'mytheme_exclude_cats'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>Hope this helps.</p>
]]></content:encoded>
			<wfw:commentRss>http://zenverse.net/wordpress-exclude-categories/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to Create A Standalone WordPress Custom PHP Page</title>
		<link>http://zenverse.net/how-to-create-a-standalone-wordpress-custom-php-page/</link>
		<comments>http://zenverse.net/how-to-create-a-standalone-wordpress-custom-php-page/#comments</comments>
		<pubDate>Fri, 05 Aug 2011 14:33:41 +0000</pubDate>
		<dc:creator>Zen</dc:creator>
				<category><![CDATA[Wordpress Development]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://zenverse.net/?p=2107</guid>
		<description><![CDATA[The term "Standalone" here refers to a page that run using WordPress engine but does not display using your WordPress theme. It means that your page can access all PHP functions in WordPress but you get to decide how the page looks like. The good news is, to do this using WordPress is amazingly easy.]]></description>
			<content:encoded><![CDATA[<p>The term &#8220;Standalone&#8221; here refers to a page that run using WordPress engine but does not display using your WordPress theme. It means that your page can access all PHP functions in WordPress but you get to decide how the page looks like. The good news is, to do this using WordPress is amazingly easy.</p>
<h3>Loading WordPress Engine</h3>
<p>First thing to do is to load the WordPress core engine file, wp-load.php. Depends on where you want to put your custom page, you just need to use require_once(&#8216;wp-load.php&#8217;), of course point it to correct folder if your custom page is in different folder.</p>
<p>In this example, i put my custom page in my WordPress root folder. Enter this in your custom page:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p2107code4'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p21074"><td class="code" id="p2107code4"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
&nbsp;
<span style="color: #b1b100;">require_once</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'wp-load.php'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//if you put in &quot;your-wordpress-root/wp-content/&quot; folder , prepend with &quot;../&quot; to go &quot;1 folder up&quot;</span>
<span style="color: #666666; font-style: italic;">//require_once('../wp-load.php');</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p>Congratulations, you just created a standalone WordPress custom PHP page. Isn&#8217;t that easy?</p>
<h3>Making the page Admin-Only</h3>
<p>Very often you need limit access to your page to your blog admins only. You can check if the user is an admin after the require_once() statement:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p2107code5'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p21075"><td class="code" id="p2107code5"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
&nbsp;
<span style="color: #b1b100;">require_once</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'wp-load.php'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #339933;">!</span>is_user_logged_in<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #339933;">!</span>current_user_can<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'manage_options'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<a href="http://www.php.net/die"><span style="color: #990000;">die</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Please login as admin to use this page.'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//your page content here</span></pre></td></tr></table></div>

<p>As we said previously, after we loaded wp-load.php, we then have access to all WordPress functions, that is why we can use is_user_logged_in() and current_user_can() to check the user. </p>
<p>&#8220;manage_options&#8221; is the capability we used to check if the user is admin because all admins can &#8220;manage_options&#8221;. For more capabilities other than just &#8220;manage_options&#8221;, please refer to the <a href="http://codex.wordpress.org/Roles_and_Capabilities" target="_blank">WordPress Codex on Roles &#038; Capabilities</a>.</p>
<p>Hope this helps <img src='http://zenverse.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://zenverse.net/how-to-create-a-standalone-wordpress-custom-php-page/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>How to Fix FTP Login Problem in WordPress in XAMPP for Mac OS (Localhost)</title>
		<link>http://zenverse.net/wordpress-ftp-login-problem-xampp-mac-localhost/</link>
		<comments>http://zenverse.net/wordpress-ftp-login-problem-xampp-mac-localhost/#comments</comments>
		<pubDate>Tue, 12 Jul 2011 15:44:29 +0000</pubDate>
		<dc:creator>Zen</dc:creator>
				<category><![CDATA[Mac]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[mac]]></category>
		<category><![CDATA[wordpress]]></category>
		<category><![CDATA[xampp]]></category>

		<guid isPermaLink="false">http://zenverse.net/?p=2047</guid>
		<description><![CDATA[If you are using XAMPP for Mac OS like me, and was asked to enter FTP login information when you upgrade Wordpress core and download themes or plugins, then this guide is for you. After searching for solution online, I found that this is a permission problem due to your Mac's username is different compared to the default user name in XAMPP for Mac, called nobody.]]></description>
			<content:encoded><![CDATA[<p>If you are using XAMPP for Mac OS like me, and was asked to enter FTP login information when you upgrade WordPress core and download themes or plugins, then this guide is for you. After searching for solution online, I found that this is a permission problem due to your Mac&#8217;s username is different compared to the default user name in XAMPP for Mac, called nobody.</p>
<p>As far as I understand, this has nothing to do with FTP settings. This problem occurs because the Apache HTTP service was being run as &#8220;nobody&#8221; while your Mac user name is a different name. Thus, it has no permission to add/edit your server files so WordPress attempted to use FTP to perform its job.</p>
<h3>Editing httpd.conf as Admin</h3>
<p>First of all, editing this file is not as easy as using a text editor program and edit it because this read-only file can only be changed by root or superuser, not even administrator. There are 2 or more methods that you use to edit such file:</p>
<blockquote><p>1. Edit using vi editor in sudo mode using Terminal<br />
<strong>2. Run Mac OS TextEditor in sudo mode using Terminal and edit the file</strong></p></blockquote>
<p>- Terminal is a command line tool just like Window&#8217;s CMD.<br />
- Sudo mode refers to running the file as superuser or root.<br />
- Vi editor is a command line editor that is very not user-friendly to use, edit and save (at least for beginner)</p>
<p>Thus we will use Method 2 to perform this task.</p>
<h3>1. Run Mac OS TextEditor application in sudo mode using Terminal and edit the file</h3>
<p>First of all, open up your Terminal by typing &#8220;Terminal&#8221; in your Spotlight search box (upper right corner)</p>
<p>Once the terminal is loaded, type this in: (copy and paste if possible)</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p2047code6'); return false;">View Code</a> TERMINAL</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p20476"><td class="code" id="p2047code6"><pre class="terminal" style="font-family:monospace;">sudo /Applications/TextEdit.app/Contents/MacOS/TextEdit /Applications/XAMPP/etc/httpd.conf</pre></td></tr></table></div>

<p>- sudo command will run the TextEdit application as root<br />
- Seperated by a space after the application path, is the path of httpd.conf (the file to edit)</p>
<p>Press enter, a TextEdit window should pop up and you can then freely edit the file as root.</p>
<h3>2. Change the user name and group name</h3>
<p>Now, look for these 2 lines:</p>
<blockquote><p>User nobody<br />
Group admin</p></blockquote>
<p>Change them to:</p>
<blockquote><p>User your-mac-username<br />
Group staff</p></blockquote>
<p>- Staff is the non-admin user group in Mac.<br />
- If you are not sure about your mac username, open Finder > go to Macintosh HD > Users > Look for your folder&#8217;s name.</p>
<p>Now restart your XAMPP apache server and it should be working perfectly.</p>
]]></content:encoded>
			<wfw:commentRss>http://zenverse.net/wordpress-ftp-login-problem-xampp-mac-localhost/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>How to List All Categories, Pages and Their ID in WordPress</title>
		<link>http://zenverse.net/list-all-categories-pages-id-in-wordpress/</link>
		<comments>http://zenverse.net/list-all-categories-pages-id-in-wordpress/#comments</comments>
		<pubDate>Wed, 15 Dec 2010 16:19:44 +0000</pubDate>
		<dc:creator>Zen</dc:creator>
				<category><![CDATA[Wordpress Development]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://zenverse.net/?p=1712</guid>
		<description><![CDATA[If you are a developer, in some cases you need to get all categories and their IDs. You might start referring to wordpress codex but most likely you will end up with no solution, just like me. Rather than counting on wordpress's built-in function, you can write your own MySQL query to accomplish this.]]></description>
			<content:encoded><![CDATA[<p>If you are a developer, in some cases you need to get all categories and their IDs. You might start referring to wordpress codex but most likely you will end up with no solution, just like me. Rather than counting on wordpress&#8217;s built-in function, you can write your own MySQL query to accomplish this.</p>
<h4>MySQL query that pulls all categories from database</h4>
<p></p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p1712code7'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p17127"><td class="code" id="p1712code7"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
&nbsp;
<span style="color: #000088;">$result</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/mysql_query"><span style="color: #990000;">mysql_query</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;SELECT &quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$table_prefix</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;terms.term_id, &quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$table_prefix</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;terms.name,&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$table_prefix</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;term_taxonomy.taxonomy FROM &quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$table_prefix</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;terms INNER JOIN &quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$table_prefix</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;term_taxonomy ON &quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$table_prefix</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;terms.term_id = &quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$table_prefix</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;term_taxonomy.term_id WHERE &quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$table_prefix</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;term_taxonomy.taxonomy = 'category'&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">while</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$row</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/mysql_fetch_assoc"><span style="color: #990000;">mysql_fetch_assoc</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$result</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<span style="color: #666666; font-style: italic;">// uncomment the line below to view the content of $row</span>
<span style="color: #666666; font-style: italic;">// var_dump($row);</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// category ID = $row['term_id']</span>
<span style="color: #666666; font-style: italic;">// category name = $row['name']</span>
&nbsp;
<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$row</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'name'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">' - ID '</span><span style="color: #339933;">.</span><span style="color: #000088;">$row</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'term_id'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&lt;br /&gt;'</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p><em>$table_prefix</em> is a variable declared in wp-config.php, it carries value &#8220;wp_&#8221; by default unless you changed the setting. It is your SQL tables&#8217; prefix.</p>
<p>WordPress stores all category, tags, etc in <em>wp_term_taxonomy</em> table so we can load all categories name and ID from there.</p>
<h4>What about Pages?</h4>
<p></p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p1712code8'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p17128"><td class="code" id="p1712code8"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
&nbsp;
<span style="color: #000088;">$result</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/mysql_query"><span style="color: #990000;">mysql_query</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;SELECT post_title, ID FROM &quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$table_prefix</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;posts WHERE post_type = 'page' AND post_status = 'publish';&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">while</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$row</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/mysql_fetch_assoc"><span style="color: #990000;">mysql_fetch_assoc</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$result</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<span style="color: #666666; font-style: italic;">// uncomment the line below to view the content of $row</span>
<span style="color: #666666; font-style: italic;">// var_dump($row);</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// page ID = $row['ID']</span>
<span style="color: #666666; font-style: italic;">// page name = $row['post_title']</span>
&nbsp;
<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$row</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'post_title'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">' - ID '</span><span style="color: #339933;">.</span><span style="color: #000088;">$row</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'ID'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&lt;br /&gt;'</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p>WordPress stores all pages in <em>wp_posts</em> table, but with <em>post_type</em> set as &#8220;page&#8221;.</p>
<p>Hope this helps.</p>
]]></content:encoded>
			<wfw:commentRss>http://zenverse.net/list-all-categories-pages-id-in-wordpress/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Creating A Simple WordPress Plugin That Modifies Post Content</title>
		<link>http://zenverse.net/creating-a-simple-wordpress-plugin-that-modifies-post-content/</link>
		<comments>http://zenverse.net/creating-a-simple-wordpress-plugin-that-modifies-post-content/#comments</comments>
		<pubDate>Tue, 29 Jun 2010 09:14:21 +0000</pubDate>
		<dc:creator>Zen</dc:creator>
				<category><![CDATA[Wordpress Development]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://zenverse.net/?p=1648</guid>
		<description><![CDATA[In some occasion, you might need to add a same piece of codes to your blog posts over and over again, and when you need to make changes to them, you need to manually change all of them. This is very tedious. Not anymore, if you make a plugin that does the purpose. ]]></description>
			<content:encoded><![CDATA[<p>In some occasion, you might need to add a same piece of codes to your blog posts over and over again, and when you need to make changes to them, you need to manually change all of them. This is very tedious. Not anymore, if you make a plugin that does the purpose. </p>
<p>In this guide, we are going to create a simple plugin that scan through the post content for &#8220;{donationcode}&#8221; and replace it with our paypal donation codes. <a href="#completecode">Jump to complete code</a></p>
<h3>1. Creating a new plugin php file</h3>
<p>We created a file called <em>simple_replacer.php</em> and put it into <em>wp-content/plugins/simple_replacer/</em> folder.</p>
<h3>2. The plugin header</h3>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p1648code9'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p16489"><td class="code" id="p1648code9"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #666666; font-style: italic;">/*
Plugin Name: Simple Replacer
Plugin URI: link to your page to download the plugin or usage guide
Description: Replaces {donationcode} with paypal donation codes
Author: Zen
Version: 1.0
Author URI: http://zenverse.net/
*/</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<h3>3. Adding a function that does the replacing work</h3>
<p>Type these codes into the file after the header part (after */)</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p1648code10'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p164810"><td class="code" id="p1648code10"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> the_replacer<span style="color: #009900;">&#40;</span><span style="color: #000088;">$content</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
<span style="color: #000088;">$post</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/str_replace"><span style="color: #990000;">str_replace</span></a><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'{donationcode}'</span> <span style="color: #339933;">,</span> <span style="color: #0000ff;">'YOUR_DONATION_HTML_CODES'</span> <span style="color: #339933;">,</span> <span style="color: #000088;">$content</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">return</span> <span style="color: #000088;">$content</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>NOTE:<br />
Without returning the variable $content, you will ruin the whole post content (return empty content), so make sure you include the &#8220;return&#8221; line.</p>
<h3>4. Adding filter, let wordpress know what we want to do</h3>
<p>Add this, 1 line before the php closing tag (?>)</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p1648code11'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p164811"><td class="code" id="p1648code11"><pre class="php" style="font-family:monospace;">add_filter<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'the_content'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'the_replacer'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//if you want to run the function on excerpts too, uncomment the line below</span>
<span style="color: #666666; font-style: italic;">//add_filter('the_excerpt', 'the_replacer');</span></pre></td></tr></table></div>

<p>NOTE:<br />
The function name &#8220;the_replacer&#8221; must match the php function that you created in step 3.</p>
<h3><a name="completecode"></a>The Complete Code</h3>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p1648code12'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p164812"><td class="code" id="p1648code12"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #666666; font-style: italic;">/*
Plugin Name: Simple Replacer
Plugin URI: link to your page to download the plugin or usage guide
Description: Replaces {donationcode} with paypal donation codes
Author: Zen
Version: 1.0
Author URI: http://zenverse.net/
*/</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> the_replacer<span style="color: #009900;">&#40;</span><span style="color: #000088;">$content</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
<span style="color: #000088;">$post</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/str_replace"><span style="color: #990000;">str_replace</span></a><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'{donationcode}'</span> <span style="color: #339933;">,</span> <span style="color: #0000ff;">'YOUR_DONATION_HTML_CODES'</span> <span style="color: #339933;">,</span> <span style="color: #000088;">$content</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">return</span> <span style="color: #000088;">$content</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
&nbsp;
add_filter<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'the_content'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'the_replacer'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//if you want to run the function on excerpts too, uncomment the line below</span>
<span style="color: #666666; font-style: italic;">//add_filter('the_excerpt', 'the_replacer');</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p>That&#8217;s it. </p>
]]></content:encoded>
			<wfw:commentRss>http://zenverse.net/creating-a-simple-wordpress-plugin-that-modifies-post-content/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Adding Post Thumbnail Feature to your WordPress Theme</title>
		<link>http://zenverse.net/adding-post-thumbnail-feature-to-your-wordpress-theme/</link>
		<comments>http://zenverse.net/adding-post-thumbnail-feature-to-your-wordpress-theme/#comments</comments>
		<pubDate>Mon, 22 Feb 2010 13:26:26 +0000</pubDate>
		<dc:creator>Zen</dc:creator>
				<category><![CDATA[Wordpress Development]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://zenverse.net/?p=1512</guid>
		<description><![CDATA[Wordpress added a new major feature in version 2.9 - The Post Thumbnail. Now everyone can easily make your website looks more magazine-like and professional. I will show you how to add the feature to your theme within 5 minutes.]]></description>
			<content:encoded><![CDATA[<p>WordPress added a new major feature in version 2.9 &#8211; The Post Thumbnail. Now everyone can easily make your website looks more magazine-like and professional. I will show you how to add the feature to your theme within 5 minutes.</p>
<h3>1. Adding codes to The Loop</h3>
<p>First of all, if you do not know what is The Loop, please refer to this <a target="_blank" rel="nofollow" href="http://codex.wordpress.org/The_Loop">page</a>.</p>
<p>Open up index.php, look for:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p1512code13'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p151213"><td class="code" id="p1512code13"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> the_excerpt<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></pre></td></tr></table></div>

<p>or, your theme may be using this instead of that above:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p1512code14'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p151214"><td class="code" id="p1512code14"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> the_content<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></pre></td></tr></table></div>

<p>Add these codes <strong>just before</strong> the &#8220;the_excerpt&#8221; or &#8220;the_content&#8221; line :</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p1512code15'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p151215"><td class="code" id="p1512code15"><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><a href="http://www.php.net/function_exists"><span style="color: #990000;">function_exists</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'has_post_thumbnail'</span><span style="color: #009900;">&#41;</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> has_post_thumbnail<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: #339933;">&lt;</span>a href<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;&lt;?php the_permalink(); ?&gt;&quot;</span><span style="color: #339933;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;?</span>php the_post_thumbnail<span style="color: #009900;">&#40;</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span> <span style="color: #cc66cc;">150</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">150</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'class'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'alignleft'</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span><span style="color: #339933;">&lt;/</span>a<span style="color: #339933;">&gt;</span>
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #009900;">&#125;</span> <span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p><u>Explaination:</u></p>
<ul>
<li>The first line check whether &#8220;has_post_thumbnail&#8221; function exists before running the code, so that it wouldn&#8217;t causes fatal error in older wordpress version.</li>
<li><em>has_post_thumbnail</em> is the function that determine whether your post has post thumbnail</li>
<li><em>the_post_thumbnail </em>is the function that output the post thumbnail &lt;img> tag</li>
</ul>
<p>.</p>
<h3>2. Using the_post_thumbnail()</h3>
<p>According to the <a href="http://codex.wordpress.org/Template_Tags/the_post_thumbnail" target="_blank" rel="nofollow">wordpress codex</a>, the function&#8217;s usage is:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p1512code16'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p151216"><td class="code" id="p1512code16"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> the_post_thumbnail<span style="color: #009900;">&#40;</span> <span style="color: #000088;">$size</span><span style="color: #339933;">,</span> <span style="color: #000088;">$attr</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p>It can accept 2 arguments. The first argument is the thumbnail size and the second argument is the image&#8217;s attributes.</p>
<p><b>Based on the example in part 1</b><br />
I used to specify the thumbnail size in array form, like in the above example (a square thumbnail of 150 pixels).</p>
<p>For the second argument, I added <i>.alignleft</i> class to the thumbnail so that it floats left. You can add more attributes like this too:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p1512code17'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p151217"><td class="code" id="p1512code17"><pre class="php" style="font-family:monospace;">the_post_thumbnail<span style="color: #009900;">&#40;</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span> <span style="color: #cc66cc;">150</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">150</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'class'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'alignleft'</span> <span style="color: #339933;">,</span> style<span style="color: #0000ff;">' =&gt; '</span>border<span style="color: #339933;">:</span>1px solid red <span style="color: #339933;">;</span> margin<span style="color: #339933;">-</span>right<span style="color: #339933;">:</span>5px <span style="color: #339933;">;</span><span style="color: #0000ff;">' ) );</span></pre></td></tr></table></div>

<h3>3. Make your theme support post thumbnail</h3>
<p>Open functions.php, scroll to the most bottom and add this before ?> (the closing php tag) :</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p1512code18'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p151218"><td class="code" id="p1512code18"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <a href="http://www.php.net/function_exists"><span style="color: #990000;">function_exists</span></a><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'add_theme_support'</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
add_theme_support<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'post-thumbnails'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>Visit your admin panel and edit/create a post, you will then notice a new box called &#8220;Post Thumbnail&#8221; appear at the bottom right corner. You can add thumbnail there.</p>
<h3>4. I need rectangle thumbnail</h3>
<p>When you upload a thumbnail, wordpress generates only square thumbnails. What if you need rectangle thumbnail in your theme?</p>
<p>In your functions.php, look for:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p1512code19'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p151219"><td class="code" id="p1512code19"><pre class="php" style="font-family:monospace;">add_theme_support<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'post-thumbnails'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>After that, add this in the next line:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p1512code20'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p151220"><td class="code" id="p1512code20"><pre class="php" style="font-family:monospace;">set_post_thumbnail_size<span style="color: #009900;">&#40;</span> <span style="color: #cc66cc;">300</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">100</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">true</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>The first argument is width, second is height and the third is crop_flag (if true, wordpress will crop it upon creating the thumbnail, instead of resizing)</p>
<p>From now on, wordpress will generate an additional rectangle thumbnail of size 300 x 100 pixels everytime you upload image. </p>
<p>Okay, you might ask, what about my old uploaded images? I want each of them to have a rectangle thumbnail too. Fortunately, there is a plugin called &#8220;Regenerate Thumbnails&#8221; which can do the job for you automatically.</p>
<p>Hope this helps <img src='http://zenverse.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://zenverse.net/adding-post-thumbnail-feature-to-your-wordpress-theme/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Fatal Error When Using has_post_image() and the_post_image()</title>
		<link>http://zenverse.net/fatal-error-when-using-has_post_image-and-the_post_image/</link>
		<comments>http://zenverse.net/fatal-error-when-using-has_post_image-and-the_post_image/#comments</comments>
		<pubDate>Tue, 05 Jan 2010 04:34:38 +0000</pubDate>
		<dc:creator>Zen</dc:creator>
				<category><![CDATA[Wordpress Development]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://zenverse.net/?p=1432</guid>
		<description><![CDATA[If you followed guides for the new post thumbnail feature before Wordpress 2.9 is out, they might tell you to paste this codes (or similar) into <strong>The Loop</strong>. However, the functions names actually changed when Wordpress 2.9 is out.]]></description>
			<content:encoded><![CDATA[<p>If you followed guides for the new post thumbnail feature before WordPress 2.9 is out, they might tell you to paste this codes (or similar) into <strong>The Loop</strong>.</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p1432code21'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p143221"><td class="code" id="p1432code21"><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> has_post_image<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: #339933;">&lt;</span>a href<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;&lt;?php the_permalink(); ?&gt;&quot;</span><span style="color: #339933;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;?</span>php the_post_image<span style="color: #009900;">&#40;</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span> <span style="color: #cc66cc;">125</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">125</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'class'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'alignleft'</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span><span style="color: #339933;">&lt;/</span>a<span style="color: #339933;">&gt;</span>
<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>However, the function names above were based on wordpress 2.9 RC1. The functions names actually changed when WordPress 2.9 is out. </p>
<ul>
<li>has_post_image() -> has_post_thumbnail()</li>
<li>the_post_image() -> the_post_thumbnail()</li>
</ul>
<p>So the codes you need to use is:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p1432code22'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p143222"><td class="code" id="p1432code22"><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> has_post_thumbnail<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: #339933;">&lt;</span>a href<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;&lt;?php the_permalink(); ?&gt;&quot;</span><span style="color: #339933;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;?</span>php the_post_thumbnail<span style="color: #009900;">&#40;</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span> <span style="color: #cc66cc;">125</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">125</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'class'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'alignleft'</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span><span style="color: #339933;">&lt;/</span>a<span style="color: #339933;">&gt;</span>
<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>That&#8217;s it.</p>
]]></content:encoded>
			<wfw:commentRss>http://zenverse.net/fatal-error-when-using-has_post_image-and-the_post_image/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>WordPress 2.9 Carmen With Exciting New Features</title>
		<link>http://zenverse.net/wordpress-2-9-carmen/</link>
		<comments>http://zenverse.net/wordpress-2-9-carmen/#comments</comments>
		<pubDate>Sun, 20 Dec 2009 07:17:58 +0000</pubDate>
		<dc:creator>Zen</dc:creator>
				<category><![CDATA[Wordpress Development]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://zenverse.net/?p=1413</guid>
		<description><![CDATA[WordPress version 2.9 "Carmen" named in honor of magical jazz vocalist <a rel="nofollow" target="_blank" href="http://www.carmenmcrae.com/">Carmen McRae</a> is available for download. I will soon check and make required changes for all my themes.]]></description>
			<content:encoded><![CDATA[<p>WordPress version 2.9 &#8220;Carmen&#8221; named in honor of magical jazz vocalist <a rel="nofollow" target="_blank" href="http://www.carmenmcrae.com/">Carmen McRae</a> is available for download. I will soon check and make required changes for all my themes.</p>
<h3>New Major Features</h3>
<ul>
<li><strong>&#8220;Trash&#8221; feature</strong>, if you accidentally delete a post or comment you can bring it back, just like your OS.</li>
<li><strong>Built-in image editor</strong> that allows you to crop, edit, rotate, flip, and scale your images.</li>
<li><strong>Batch plugin update and compatibility checking</strong> which means you can update 10 plugins at once</li>
<li><strong>Easier video embeds</strong> that allow you to just paste a URL on its own line and have it magically turn it into the proper embed code.</li>
<li><strong>Custom post types</strong> so you can juggle more types than just post, page, and attachment.</li>
<li><strong>Sidebars can now have descriptions</strong> so it’s more obvious what and where they do what they do.</li>
<li><strong>Automatic database optimization support</strong>, which you can enable in your wp-config.php file by adding define(&#8216;WP_ALLOW_REPAIR&#8217;, true);.</li>
<li><strong>Rel=canonical support for better SEO</strong>. <a rel="nofollow" target="_blank" href="http://googlewebmastercentral.blogspot.com/2009/02/specify-your-canonical.html">What is rel=&#8221;canonical&#8221;?</a></li>
<li><strong>Themes can register &#8220;post thumbnails&#8221;</strong> which allow them to attach an image to the post.</li>
<li>When you’re editing files in the theme and plugin editors it remembers your location and takes you back to that line after you save.</li>
</ul>
<h3>More Info &#038; Links</h3>
<ul>
<li><a rel="nofollow" target="_blank" href="http://wordpress.org/development/2009/12/wordpress-2-9/">Video and full list of new features in WordPress 2.9 @ Official Dev Blog</a></li>
<li><a rel="nofollow" target="_blank" href="http://wordpress.org/download/">Download WordPress 2.9</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://zenverse.net/wordpress-2-9-carmen/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Using Template Tag Function in WordPress Theme Demo Bar Plugin</title>
		<link>http://zenverse.net/using-template-tag-function-in-wordpress-theme-demo-bar-plugin/</link>
		<comments>http://zenverse.net/using-template-tag-function-in-wordpress-theme-demo-bar-plugin/#comments</comments>
		<pubDate>Thu, 10 Sep 2009 09:23:18 +0000</pubDate>
		<dc:creator>Zen</dc:creator>
				<category><![CDATA[Wordpress Development]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://zenverse.net/?p=874</guid>
		<description><![CDATA[Explains the template tag functions for wordpress theme demo bar plugin. Currently there are:
<ul>
<li>wptdb_output()</li>
<li>wptdb_list_themes()</li>
</ul>]]></description>
			<content:encoded><![CDATA[<p>This page is created for <a target="_blank" href="http://zenverse.net/wordpress-theme-demo-bar-plugin/">WordPress Theme Demo Bar</a> plugin.</p>
<blockquote><p>There are 2 functions available : </p>
<ul>
<li><a href="#wptdb_output">wptdb_output()</a></li>
<li><a href="#wptdb_list_themes">wptdb_list_themes()</a></li>
</ul>
</blockquote>
<h3>Function : wptdb_output()<a name="wptdb_output"></a></h3>
<p>Please read &#8221; <a target="_blank" href="http://zenverse.net/using-shortcode-in-wordpress-theme-demo-bar-plugin/">Using shortcode</a> &#8221; first to understand this page better.</p>
<h5>Description</h5>
<p>Allows you to output theme info in template files instead of using shortcode in post. It accepts argument in strings and works exactly like the shortcode <img style="vertical-align:middle" src="http://zenverse.net/wp-content/uploads/2009/09/demobar_shortcode.gif" alt="" />. Introduced in version 1.4.</p>
<h5>Usage</h5>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p874code23'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p87423"><td class="code" id="p874code23"><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> <a href="http://www.php.net/function_exists"><span style="color: #990000;">function_exists</span></a> <span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'wptdb_output'</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
wptdb_output<span style="color: #009900;">&#40;</span><span style="color: #000088;">$args</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<h5>Parameters</h5>
<p><strong>theme</strong><br />
(<em>string</em>) The theme&#8217;s folder name. Must be set.</p>
<p><strong>format</strong><br />
(<em>string</em>) Format id. Default format will be used if you give an invalid format id.</p>
<p><strong>get</strong><br />
(<em>string</em>) Get single info instead of using format.<br />
Valid values : <a target="_blank" rel="nofollow" href="http://zenverse.net/wp-content/plugins/wordpress-theme-demo-bar/listoftags.html">All available tags</a></p>
<p><strong>autop</strong><br />
(<em>string</em>) Auto wrap the content with HTML paragraph &lt;p> tag</p>
<ul>
<li>true &#8211; default</li>
<li>false / 0 (to display content inline)</li>
</ul>
<p><strong>echo</strong><br />
(<em>string</em>) Show the result or keep it in a variable. Default is true.</p>
<ul>
<li>1 (true) &#8211; default</li>
<li>0 (false)</li>
</ul>
<h5>Example of Usage</h5>
<p><strong>Display format id of 1</strong></p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p874code24'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p87424"><td class="code" id="p874code24"><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> <a href="http://www.php.net/function_exists"><span style="color: #990000;">function_exists</span></a> <span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'wptdb_output'</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
wptdb_output<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'theme=my-theme-folder-name&amp;format=1'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p><strong>Display number of previews (inline)</strong></p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p874code25'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p87425"><td class="code" id="p874code25"><pre class="php" style="font-family:monospace;">Lunated theme has <span style="color: #000000; font-weight: bold;">&lt;?php</span> 
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <a href="http://www.php.net/function_exists"><span style="color: #990000;">function_exists</span></a> <span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'wptdb_output'</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
wptdb_output<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'theme=lunated&amp;get=hits&amp;autop=false'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span> previews in total<span style="color: #339933;">.</span></pre></td></tr></table></div>

<p><strong>Assign to variable</strong></p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p874code26'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p87426"><td class="code" id="p874code26"><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> <a href="http://www.php.net/function_exists"><span style="color: #990000;">function_exists</span></a> <span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'wptdb_output'</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<span style="color: #000088;">$stored</span> <span style="color: #339933;">=</span> wptdb_output<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'theme=lunated&amp;get=today&amp;echo=0'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$stored</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p><strong>Argument in array form</strong></p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p874code27'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p87427"><td class="code" id="p874code27"><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> <a href="http://www.php.net/function_exists"><span style="color: #990000;">function_exists</span></a> <span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'wptdb_output'</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<span style="color: #000088;">$stored</span> <span style="color: #339933;">=</span> wptdb_output<span style="color: #009900;">&#40;</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span>
<span style="color: #0000ff;">'theme'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'lunated'</span><span style="color: #339933;">,</span>
<span style="color: #0000ff;">'get'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'today'</span><span style="color: #339933;">,</span>
<span style="color: #0000ff;">'echo'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'0'</span><span style="color: #339933;">,</span>
<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$stored</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<h3>Function : wptdb_list_themes()<a name="wptdb_list_themes"></a></h3>
<h5>Description</h5>
<p>Allows you to display a drop-down menu (&lt;select>) for visitors to choose and preview your non-private themes. Introduced in version 1.5</p>
<h5>Usage</h5>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p874code28'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p87428"><td class="code" id="p874code28"><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> <a href="http://www.php.net/function_exists"><span style="color: #990000;">function_exists</span></a> <span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'wptdb_list_themes'</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
wptdb_list_themes<span style="color: #009900;">&#40;</span><span style="color: #000088;">$args</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<h5>Parameters</h5>
<p><strong>style</strong><br />
(<em>string</em>) Type of output. Default is &#8220;option&#8221; which output &lt;option> to be used with &lt;select>. Valid values:</p>
<ul>
<li>option &#8211; default</li>
</ul>
<p><strong>hierarchical</strong><br />
(<em>string</em>) Show parent-child relationship. Default is true. Valid values:</p>
<ul>
<li>1 / true (true) &#8211; default</li>
<li>0 / false (false)</li>
</ul>
<p><strong>orderby</strong><br />
(<em>string</em>) Sort themes by wordpress default method or by number of previews. Valid values:</p>
<ul>
<li>default &#8211; default</li>
<li>hits</li>
</ul>
<p><strong>order</strong><br />
(<em>string</em>) Sort order for themes (either ascending or descending). Default is asc. Valid values:</p>
<ul>
<li>asc &#8211; default</li>
<li>desc</li>
</ul>
<p><strong>show_hits</strong><br />
(<em>string</em>) Show number of previews beside theme name in a bracket. Default is false. Valid values:</p>
<ul>
<li>true / 1</li>
<li>false / 0 &#8211; default</li>
</ul>
<p><strong>echo</strong><br />
(<em>string</em>) Show the result or keep it in a variable. Default is true.</p>
<ul>
<li>1 (true) &#8211; default</li>
<li>0 (false)</li>
</ul>
<h5>Example of Usage</h5>
<p><strong>Display drop-down menu using default settings</strong></p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p874code29'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p87429"><td class="code" id="p874code29"><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> <a href="http://www.php.net/function_exists"><span style="color: #990000;">function_exists</span></a> <span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'wptdb_list_themes'</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'&lt;select name=&quot;&quot;&gt;'</span><span style="color: #339933;">;</span>
wptdb_list_themes<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'&lt;/select&gt;'</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p><strong>Display drop-down menu , sort the themes by number of previews in descending order</strong></p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p874code30'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p87430"><td class="code" id="p874code30"><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> <a href="http://www.php.net/function_exists"><span style="color: #990000;">function_exists</span></a> <span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'wptdb_list_themes'</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'&lt;select name=&quot;&quot;&gt;'</span><span style="color: #339933;">;</span>
wptdb_list_themes<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'orderby=hits&amp;order=desc'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'&lt;/select&gt;'</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p><strong>Display drop-down menu with number of previews shown beside the theme name</strong></p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p874code31'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p87431"><td class="code" id="p874code31"><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> <a href="http://www.php.net/function_exists"><span style="color: #990000;">function_exists</span></a> <span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'wptdb_list_themes'</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'&lt;select name=&quot;&quot;&gt;'</span><span style="color: #339933;">;</span>
wptdb_list_themes<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'show_hits=1'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'&lt;/select&gt;'</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p><strong>Argument in array form</strong></p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p874code32'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p87432"><td class="code" id="p874code32"><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> <a href="http://www.php.net/function_exists"><span style="color: #990000;">function_exists</span></a> <span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'wptdb_list_themes'</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'&lt;select name=&quot;&quot;&gt;'</span><span style="color: #339933;">;</span>
wptdb_list_themes<span style="color: #009900;">&#40;</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span>
<span style="color: #0000ff;">'orderby'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'hits'</span><span style="color: #339933;">,</span>
<span style="color: #0000ff;">'order'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'desc'</span><span style="color: #339933;">,</span>
<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'&lt;/select&gt;'</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://zenverse.net/using-template-tag-function-in-wordpress-theme-demo-bar-plugin/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Understanding &amp; Using Shortcode in WordPress Theme Demo Bar Plugin</title>
		<link>http://zenverse.net/using-shortcode-in-wordpress-theme-demo-bar-plugin/</link>
		<comments>http://zenverse.net/using-shortcode-in-wordpress-theme-demo-bar-plugin/#comments</comments>
		<pubDate>Thu, 10 Sep 2009 05:35:35 +0000</pubDate>
		<dc:creator>Zen</dc:creator>
				<category><![CDATA[Wordpress Development]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://zenverse.net/?p=841</guid>
		<description><![CDATA[Since version 1.4, you can display theme info such as number of previews and theme preview URL in posts and pages using shortcode. To make the process easier, use Media Button (see screenshot for more info)]]></description>
			<content:encoded><![CDATA[<p>This page is created for <a target="_blank" href="http://zenverse.net/wordpress-theme-demo-bar-plugin/">WordPress Theme Demo Bar</a> plugin. Shortcode is introduced in version 1.4.</p>
<h5>What can you do with shortcode <img style="vertical-align:middle" src="http://zenverse.net/wp-content/uploads/2009/09/demobar_shortcode.gif" alt="" />?</h5>
<p>You can display theme info such as number of previews in posts and pages. You can output anything within these <a target="_blank" href="http://zenverse.net/wp-content/wordpress-theme-demo-bar/listoftags.html">supported tags</a>:</p>
<ul>
<li>Name of the theme (based on style.css)</li>
<li>Description of the theme (based on style.css)</li>
<li>Theme URI (based on style.css)</li>
<li>Author name (based on style.css)</li>
<li>Version number of the theme (based on style.css)</li>
<li>Folder name of the theme</li>
</li>
<li>URL to preview the theme (?themedemo=xxx)</li>
<li>Total no. of previews</li>
<li>URL to theme&#8217;s screenshot file</li>
<li>URL to the theme&#8217;s info page (if exist)</li>
<li>URL to the theme&#8217;s download page (if exist)</li>
<li>URL to the page to buy the theme (if exist)</li>
</ul>
<h5>Example of what you can do</h5>
<p><strong>Retrieve the <u>number of previews</u> of my Lunated Theme and display it <u>inline</u></strong></p>
<blockquote><p>Oh. Lunated theme has been previewed 26675 times in total.</p></blockquote>
<p><strong>Make a preview link to Lunated theme using default format</strong></p>
<blockquote><p><a title="Lunated has been previewed 26675 times." href="/?themedemo=lunated">Preview Lunated (26675)</a></p>
</blockquote>
<h5>Understanding and Using Shortcode</h5>
<li>Generally, you need to specify the theme folder name like: <img style="vertical-align:middle" src="http://zenverse.net/wp-content/uploads/2009/09/wptdb_sc_guide_00.gif" alt="" /></li>
<li>To make it easier, you can use the media button (see screenshot for more info) and follow the steps given.</li>
<p>To understand more about the shortcode <img style="vertical-align:middle" src="http://zenverse.net/wp-content/uploads/2009/09/demobar_shortcode.gif" alt="" /> and examples:</p>
<blockquote>
<h5>1. Get Single Info only</h5>
<p><strong>Use attribute &#8216;get&#8217; to return only a single infomation</strong></p>
<p><strong>Valid values of attribute &#8216;get&#8217; :</strong><br />
<a name="tags"></a><a target="_blank" rel="nofollow" href="http://zenverse.net/wp-content/plugins/wordpress-theme-demo-bar/listoftags.html">All tags available</a> are the valid values of attribute &#8216;get&#8217;. However, you can only use one tag at once. (without curly bracket of course)</p>
<p><strong>Example:</strong></p>
<ul>
<li>Get number of previews of my Lunated theme and display it inline<br />
<img src="http://zenverse.net/wp-content/uploads/2009/09/wptdb_sc_guide_01.gif" alt="" /></li>
<li>Get URL to screenshot file of my Lunated theme and display it inline<br />
<img src="http://zenverse.net/wp-content/uploads/2009/09/wptdb_sc_guide_02.gif" alt="" /></li>
</ul>
<p><strong>You can use media button to make the whole process a lot easier.</strong>
</p></blockquote>
<blockquote>
<h5>2. Formatted Output &#8211; return output based on format id</h5>
<p><strong>use attribute &#8216;format&#8217;</strong></p>
<p><strong>you can create and save a new format at plugin option page</strong></p>
<p><strong>Default format is : &lt;a title=&quot;{name} has been previewed {hits} times&quot; href=&quot;{demo}&quot;>Preview {name} ({hits})&lt;/a></strong></p>
<p><strong>Example:</strong></p>
<ul>
<li>Display using default format (you don&#8217;t have to specify the format id)<br />
<img style="vertical-align:middle" src="http://zenverse.net/wp-content/uploads/2009/09/wptdb_sc_guide_00.gif" alt="" /></li>
<li>Display using format id 1<br />
<img src="http://zenverse.net/wp-content/uploads/2009/09/wptdb_sc_guide_03.gif" alt="" /></li>
</ul>
<p><strong>You can use media button to make the whole process a lot easier.</strong>
</p></blockquote>
<blockquote>
<h5>3. Auto wrap output content with HTML paragraph &lt;p> tag</h5>
<p><strong>use attribute &#8216;autop&#8217;</strong></p>
<p><strong>by default autop is set to true, which means it automatically wrap the output content with &lt;p> tags</strong></p>
<p><strong>To display the content inline, use autop=&#8221;false&#8221;</strong></p>
<p><strong>Example:</strong><br />
<img src="http://zenverse.net/wp-content/uploads/2009/09/wptdb_sc_guide_01.gif" alt="" />
</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://zenverse.net/using-shortcode-in-wordpress-theme-demo-bar-plugin/feed/</wfw:commentRss>
		<slash:comments>19</slash:comments>
		</item>
	</channel>
</rss>

