<?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>That PHP Girl &#187; cms</title>
	<atom:link href="http://www.thatphpgirl.com/tag/cms/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.thatphpgirl.com</link>
	<description>PHP, WordPress, and Theme Development</description>
	<lastBuildDate>Wed, 19 Oct 2011 08:03:28 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
<xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />
		<item>
		<title>WordPress for E-Commerce, Part 1</title>
		<link>http://www.thatphpgirl.com/wordpress-for-e-commerce-part-1/</link>
		<comments>http://www.thatphpgirl.com/wordpress-for-e-commerce-part-1/#comments</comments>
		<pubDate>Wed, 16 Sep 2009 18:37:35 +0000</pubDate>
		<dc:creator>Nikole Gipps</dc:creator>
				<category><![CDATA[DIY]]></category>
		<category><![CDATA[categories]]></category>
		<category><![CDATA[cms]]></category>
		<category><![CDATA[custom template]]></category>
		<category><![CDATA[ecommerce]]></category>
		<category><![CDATA[online store]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[shopping cart]]></category>
		<category><![CDATA[web development]]></category>
		<category><![CDATA[website]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[WordPress functions]]></category>

		<guid isPermaLink="false">http://thatphpgirl.com/?p=243</guid>
		<description><![CDATA[Today is part one of a three-part article on using WordPress for E-Commerce. My goal is to create a sort of how-is-that-done series on using WordPress as an easy content management tool for selling actual products. Some of these techniques can be implemented by anyone, whether you are an advanced programmer or a beginner to [...]]]></description>
			<content:encoded><![CDATA[<p>Today is part one of a three-part article on using WordPress for E-Commerce. My goal is to create a sort of how-is-that-done series on using WordPress as an easy content management tool for selling actual products. Some of these techniques can be implemented by anyone, whether you are an advanced programmer or a beginner to WordPress. Today&#8217;s example is from <a href="http://rockstarweddingplanner.com" target="_new">Rockstar Wedding Planner</a>, a recently relaunched site by <a href="http://www.thatphpgirl.com">That PHP Girl</a>.</p>
<h3>Why Use WordPress for E-Commerce?</h3>
<p>I have yet to find an e-commerce solution that I really like and that will do everything I need. Most of them are very complicated to do custom design on, or they are limited in terms of custom design in order to maintain functionality. The time-consuming nature of customizing e-commerce software is what makes an e-commerce site so expensive to make &#8230; and to be honest, most people don&#8217;t need a full-blown e-commerce solution because they won&#8217;t use most of the functionality, and/or they have very few products. Many people also don&#8217;t want a real store&mdash;they just want a way to throw in a few products into their content. So for those reasons, along with the ease of use and development of WordPress, finding a way to make WordPress work for e-commerce purposes makes sense.</p>
<h3>Anatomy of a Products Post</h3>
<p><a href="http://rockstarweddingplanner.com" target="_new">Rockstar Wedding Planner</a> has two main shopping areas: The products section and the coaching section.  <a href="http://rockstarweddingplanner.com/products/" target="_new">The products section</a> is just a category listing disguised as a page &mdash; it uses <a href="http://codex.wordpress.org/Function_Reference/WP_Query" target="_new">WP_Query</a> to pull all the posts from the products posting category and orders them by title. The loop then starts to display all the posts.</p>
<p>The first section is just a simple call to the <a href="http://codex.wordpress.org/Template_Tags/the_title" target="_new">the_title();</a> function in an h3 wrapper:</p>
<p><img src="http://thatphpgirl.com/wp-content/uploads/2009/09/post_anatomy1.png" alt="the_title();" /></p>
<p>The second section calls <a href="http://codex.wordpress.org/Template_Tags/the_content" target="_new">the_content();</a>, using the &lt;!&#8211;more&#8211;&gt; quicktag to control what is displayed on the page and what is displayed after the link.</p>
<p><img src="http://thatphpgirl.com/wp-content/uploads/2009/09/post_anatomy2.png" alt="the_content();" /></p>
<p>The third section calls a price for the product, and a description for that price if it is available (which it is when there is more than one price option). It starts out by finding out if a price is listed using a <a href="http://codex.wordpress.org/Using_Custom_Fields" target="_new">custom field</a>, displaying the description if there is one, and then displaying the price.</p>
<p><img src="http://thatphpgirl.com/wp-content/uploads/2009/09/post_anatomy3.png" alt="the_content();" /></p>
<p>The code for that looks like this:</p>
<blockquote><p>&lt;?php if (post_custom(&#8216;bundle_price&#8217;) == true) { ?&gt;&lt;p&gt;&lt;?php if (post_custom(&#8216;bundle_price_descrip&#8217;) == true) { ?&gt;&lt;?php echo post_custom(&#8216;bundle_price_descrip&#8217;); ?&gt; | &lt;?php } ?&gt;Price: &lt;?php echo post_custom(&#8216;bundle_price&#8217;); ?&gt;&lt;/p&gt;&lt;?php } ?&gt;</p>
</blockquote>
<p>The fourth block is the actual add to cart button. Because the button and the surrounding code for the display stays the same for all products, I opted to just pull the link for this button from a custom field. The admin for the site simply pulls the store link for this product from their payment processor and adds it to the custom field.</p>
<p><img src="http://thatphpgirl.com/wp-content/uploads/2009/09/post_anatomy4.png" alt="Add to Cart Button" /></p>
<p>Code:</p>
<blockquote><p>&lt;?php if (post_custom(&#8216;bundle_link&#8217;) == true) { ?&gt;&lt;div class=&#8221;btn-buy&#8221;&gt;&lt;a href=&#8221;&lt;?php echo post_custom(&#8216;bundle_link&#8217;); ?&gt;&#8221;&gt;&lt;img src=&#8221;http://www.mcssl.com/netcart/images/cart_buttons/cart_button_12.gif&#8221; style=&#8221;border:none; background:none;&#8221; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;?php } ?&gt;</p>
</blockquote>
<p>The final block is a learn more link, which could possibly go to the rest of that post, or it could go to another page entirely.</p>
<p><img src="http://thatphpgirl.com/wp-content/uploads/2009/09/post_anatomy5.png" alt="Add to Cart Button" /></p>
<p>This is also accomplished through custom fields, using an if statement to determine if there is a special link, or if <a href="http://codex.wordpress.org/Template_Tags/the_permalink" target="_new">the_permalink();</a> should just be called:</p>
<blockquote><p>&lt;div class=&#8221;btn-continue&#8221;&gt;&lt;?php if (post_custom(&#8216;bundle_learnmore_link&#8217;) == true) { ?&gt;&lt;a href=&#8221;&lt;?php echo post_custom(&#8216;bundle_learnmore_link&#8217;); ?&gt;&#8221;&gt;&lt;?php echo post_custom(&#8216;bundle_learnmore_text&#8217;); ?&gt;&lt;?php } else { ?&gt;&lt;a href=&#8221;&lt;?php the_permalink(); ?&gt;&#8221;&gt;Learn More&lt;?php } ?&gt;&lt;/a&gt;&lt;/div&gt;</p>
</blockquote>
<p>The coaching section pretty much follows the same functionality, with the biggest exception being that no link is display if a learn more link is not entered as a custom field, instead of using the_permalink(); as the else alternative.</p>
<h3>Want a code-free version?</h3>
<p>WordPress is built upon the structure of categories, posts and pages. Most modern E-Commerce software is built with categories, products and extra content pages. So why can&#8217;t &quot;products&quot; just be posts in the category of &quot;products&quot;? If you want to simplify this whole thing, you could just purchase an existing theme (or use whatever you are using now), and create a category of products. Inside this category, you would use a new post for every one of your products including the description, price, and a Buy It Now button. (Buy It Now buttons can easily be created through services like <a href="http://www.google.com/checkout" target=_new">Google Checkout</a>, <a href="http://www.paypal.com" target=_new">PayPal</a> and <a href="http://www.1shoppingcart.com" target=_new">1ShoppingCart</a>.) Once you have all your products in, your &quot;store&quot; would then just be your category listing, for example /category/products/.</p>
<p>One note: Depending on your version of WordPress and how you edit your pages, it may not work to paste in button code for the visual editor. To solve this problem, enter your text into the visual editor, save the post, and then click on the HTML editor to put the button code in, clicking update post after you are done.</p>
<p>Hopefully I have given my readers some good ideas about what they can do with their own sites, but remember&mdash;if you get stuck, <a href="http://thatphpgirl.com/please-assist-me/">I&#8217;m always here to help!</a></p>
<p>Coming up: Part 2 will be on using WordPress with a custom, on-site cart solution. Part 3 will be about using a plugin to create a shopping solution.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.thatphpgirl.com/wordpress-for-e-commerce-part-1/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A Custom WordPress Blog Archives Page</title>
		<link>http://www.thatphpgirl.com/a-custom-wordpress-blog-archives-page/</link>
		<comments>http://www.thatphpgirl.com/a-custom-wordpress-blog-archives-page/#comments</comments>
		<pubDate>Sun, 02 Aug 2009 15:05:43 +0000</pubDate>
		<dc:creator>Nikole Gipps</dc:creator>
				<category><![CDATA[DIY]]></category>
		<category><![CDATA[categories]]></category>
		<category><![CDATA[category achives]]></category>
		<category><![CDATA[cms]]></category>
		<category><![CDATA[custom template]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[plugins]]></category>
		<category><![CDATA[post archives]]></category>
		<category><![CDATA[user experience]]></category>
		<category><![CDATA[web development]]></category>
		<category><![CDATA[website]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[WordPress functions]]></category>

		<guid isPermaLink="false">http://thatphpgirl.com/?p=155</guid>
		<description><![CDATA[Note: This post assumes you know how to use custom page templates in WordPress as well as know how to edit text php files and upload them through FTP. If you are already lost, you can always hire me to make your custom blog archive page for you. I make a lot of sites that [...]]]></description>
			<content:encoded><![CDATA[<p><em>Note: This post assumes you know how to use custom page templates in WordPress as well as know how to edit text php files and upload them through FTP. If you are already lost, you can always <a href="http://thatphpgirl.com/please-assist-me/">hire me to make your custom blog archive page</a> for you.</em></p>
<p>I make a lot of sites that use WordPress as a content management system (CMS) but not with the blog as the front page. For these, I use posts and categories to make various sections of the site using custom templates. My latest example of that is the Blog, Q&amp;A and Latest News sections of the site Hear Florida. For this, I wanted to make an archive page which lists all the categories, subcategories, and posts in what is technically the blog. I am sure someone is going to tell me that a plugin exists to do this thing, but as I tried two that didn&#8217;t work well, I had decided to give up and just use PHP. I also wanted to use as many standard WordPress calls as I could instead of just writing all my own functions.</p>
<p>In this exercise, this is what our final product will look like: <a href="http://www.hearflorida.com/blog-archive/">All Blog Posts Archive &raquo; Hear Florida Audiology Group</a>. It was created in a custom template called &quot;All Posts Archive&quot;. I will be breaking this down by parts and explaining what each part means to help my readers not only see the code, but to know what each part does. I will break this down piece by piece, but as a preview our final code will look like the chunk below.</p>
<blockquote><p>&lt;?php<br />
&nbsp;&nbsp;&nbsp;$all_cats = wp_list_categories(&#8216;hide_empty=0&#038;echo=0&#038;title_li=&#038;exclude=1&#8242;);<br />
&nbsp;&nbsp;&nbsp;$cats_list = explode(&quot;&lt;&quot;, $all_cats);<br />
&nbsp;&nbsp;&nbsp;$build_cat_structure = array();<br />
&nbsp;&nbsp;&nbsp;$array_counter = 0;<br />
&nbsp;&nbsp;&nbsp;foreach ($cats_list as $value) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$string_start = substr($value, 0, 3);<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if ($string_start == &quot;li &quot; || $string_start == &quot;/a&gt;&quot; || $string_start == &quot;/li&quot;) { <br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;continue; <br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;elseif ($string_start == &quot;ul &quot;) { <br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$build_cat_structure[$array_counter] = &quot;start_child&quot;; <br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$array_counter = $array_counter + 1; <br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;elseif ($string_start == &quot;/ul&quot;) { <br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$build_cat_structure[$array_counter] = &quot;end_child&quot;; <br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$array_counter = $array_counter + 1; <br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;elseif ($string_start == &quot;a h&quot;) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$cat_name = explode(&quot;&gt;&quot;, $value);<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$build_cat_structure[$array_counter] = $cat_name[1];<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$array_counter = $array_counter + 1;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br />
&nbsp;&nbsp;&nbsp;}<br />
&nbsp;&nbsp;&nbsp;echo &quot;&lt;ul&gt;&quot;;<br />
&nbsp;&nbsp;&nbsp;foreach ($build_cat_structure as $value) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if ($value == &quot;start_child&quot;) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo &quot;&lt;ul&gt;\n&quot;;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;elseif ($value == &quot;end_child&quot;) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo &quot;&lt;/ul&gt;\n&quot;;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$category_id = get_cat_id($value);<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo &#8216;&lt;li&gt;&lt;a href=&quot;&#8217; . get_category_link($category_id) . &#8216;&quot;&gt;&#8217; . category_description($category_id) . &quot;&lt;/a&gt;&lt;/li&gt;\n&quot;;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$children = wp_list_categories(&#8216;echo=0&#038;child_of=&#8217; . $category_id . &#8216;&#038;title_li=&#8217;);<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$find_me = stripos($children, &quot;No categories&quot;);<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if ($find_me !== FALSE) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo &quot;&lt;ul&gt;\n&quot;;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$the_query = new WP_Query(&#8216;cat=&#8217; . $category_id);&nbsp;&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;while ($the_query-&gt;have_posts()) : $the_query-&gt;the_post(); $do_not_duplicate = $post-&gt;ID; ?&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;li&gt;&lt;a title=&quot;&lt;?php the_title(); ?&gt;&quot; href=&quot;&lt;?php the_permalink(); ?&gt;&quot;&gt;&lt;?php the_title(); ?&gt;&lt;/a&gt;&lt;/li&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;?php endwhile;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo &quot;&lt;/ul&gt;\n&quot;;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br />
&nbsp;&nbsp;&nbsp;}<br />
&nbsp;&nbsp;&nbsp;echo &quot;&lt;/ul&gt;&quot;;<br />
?&gt;</p></blockquote>
<p>The first part pulls the categories and puts them into a list. If you wanted to shape the final outcome of the display, you could change the settings of wp_list_categories() here. For example, setting hide_empty=1 instead of 0, you could hide any categories that you have without posts. I have chosen to exclude the Uncategorized category (category #1), but if you wanted yours listed just removed the exclude=1 part. Or, if you would like to exclude other categories, just list them by number (exclude=1,5,6 for example). The echo=0 is important here because it puts the results into a variable instead of displaying them.</p>
<blockquote><p>&nbsp;&nbsp;&nbsp;$all_cats = wp_list_categories(&#8216;hide_empty=0&#038;echo=0&#038;title_li=&#038;exclude=1&#8242;);</p></blockquote>
<p>Once the result of <a href="http://codex.wordpress.org/Template_Tags/wp_list_categories">wp_list_categories</a> is dumped into the variable all_cats, it is broken apart into text chunks using the character &lt; as the divider.</p>
<blockquote><p>&nbsp;&nbsp;&nbsp;$cats_list = explode(&quot;&lt;&quot;, $all_cats);</p></blockquote>
<p>This basically puts every html chunk into it&#8217;s own entry in an array. (If at any point you want to see your results, feel free to do a var_dump($last_variable); and it will show you what you are working with.) I do this to set up the processing of the information in the next set of steps.</p>
<blockquote><p>&nbsp;&nbsp;&nbsp;$build_cat_structure = array();<br />
&nbsp;&nbsp;&nbsp;$array_counter = 0;</p></blockquote>
<p>This sets up an empty array which we will fill in the loop below, and starts our array key counter at 0.</p>
<blockquote><p>&nbsp;&nbsp;&nbsp;foreach ($cats_list as $value) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$string_start = substr($value, 0, 3);<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if ($string_start == &quot;li &quot; || $string_start == &quot;/a&gt;&quot; || $string_start == &quot;/li&quot;) { <br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;continue; <br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;elseif ($string_start == &quot;ul &quot;) { <br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$build_cat_structure[$array_counter] = &quot;start_child&quot;; <br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$array_counter = $array_counter + 1; <br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;elseif ($string_start == &quot;/ul&quot;) { <br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$build_cat_structure[$array_counter] = &quot;end_child&quot;; <br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$array_counter = $array_counter + 1; <br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;elseif ($string_start == &quot;a h&quot;) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$cat_name = explode(&quot;&gt;&quot;, $value);<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$build_cat_structure[$array_counter] = $cat_name[1];<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$array_counter = $array_counter + 1;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br />
&nbsp;&nbsp;&nbsp;}</p></blockquote>
<p>This is where I have it to loop through the array I made by the earlier <a href="http://www.php.net/explode">explode()</a> command to set up the final array which will produce the display. By taking the first three letters of each array item as a seed, I can see where the html is going and reflect that in the final build. If the string starts with something that doesn&#8217;t influence the final outcome (the start of a list item, the end of a list item, and the end of a anchor tag), the command continue is issued to loop forward on to the next item. If hierarchy is detected (the start or end of an unordered list), a designation is added into the array and the counter advances. If the start of a link is detected (&quot;a h&quot; is the start of a href), it breaks apart that line using explode to pull out the name of the category. The category name is then added to the array and the counter is advanced.</p>
<p>These last parts are where I put it all together and display the data by looping through the array I built earlier ($build_cat_structure). You could probably do this differently or combine the above and below parts instead of looping through twice, but I liked it like this so I could use the data in other ways if I wanted to.</p>
<blockquote><p>&nbsp;&nbsp;&nbsp;echo &quot;&lt;ul&gt;&quot;;<br />
&nbsp;&nbsp;&nbsp;foreach ($build_cat_structure as $value) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if ($value == &quot;start_child&quot;) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo &quot;&lt;ul&gt;\n&quot;;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;elseif ($value == &quot;end_child&quot;) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo &quot;&lt;/ul&gt;\n&quot;;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</p></blockquote>
<p>This makes/ends a nested unordered list If it hits my start/end child marker, which makes the category hierarchy work. This is also a good chance to add specific styling to the inside nest lists, if that is what you want.</p>
<blockquote><p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$category_id = get_cat_id($value);</p></blockquote>
<p>The start of the else tells the script what to do if it encounters the name of a category, or something that is not the start or end of a nested list. The next line converts our category name to a category ID using the <a href="http://codex.wordpress.org/Function_Reference/get_cat_ID">get_cat_id()</a> function.</p>
<blockquote><p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo &#8216;&lt;li&gt;&lt;a href=&quot;&#8217; . get_category_link($category_id) . &#8216;&quot;&gt;&#8217; . category_description($category_id) . &quot;&lt;/a&gt;&lt;/li&gt;\n&quot;;</p></blockquote>
<p>This displays the category in a list item with a link to the archive of that category using <a href="http://codex.wordpress.org/Function_Reference/get_category_link">get_category_link()</a>. I use <a href="http://codex.wordpress.org/Template_Tags/category_description">category_description()</a> here because my template is set up where the category name is a shorter version that is used for the sidebar and the category description is a longer version used for display. If you wanted to use the name instead, just replace category_description($category_id) with $value.</p>
<blockquote><p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$children = wp_list_categories(&#8216;echo=0&#038;child_of=&#8217; . $category_id . &#8216;&#038;title_li=&#8217;);<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$find_me = stripos($children, &quot;No categories&quot;);<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if ($find_me !== FALSE) {</p></blockquote>
<p>This special handling function checks to see if the current category is a parent of other categories. For example, on my final page (<a href="http://www.hearflorida.com/blog-archive/">All Blog Posts Archive &raquo; Hear Florida Audiology Group</a>), there is a main category of Blog for which I don&#8217;t want the posts listed. I want the posts listed under their sub categories, so it skips the post by post listing if the current category is a parent of other categories. A category that is not a parent of others will have something like &quot;&lt;li&gt;No Categories&lt;/li&gt;&quot; as the result of the above <a href="http://codex.wordpress.org/Template_Tags/wp_list_categories">wp_list_categories(child_of=)</a> call. The ($find_me !== FALSE) part creates a situation where the posts are only being displayed where the phrase &#8220;No Categories&#8221; is found.</p>
<blockquote><p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo &quot;&lt;ul&gt;\n&quot;;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$the_query = new WP_Query(&#8216;cat=&#8217; . $category_id);&nbsp;&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;while ($the_query-&gt;have_posts()) : $the_query-&gt;the_post(); $do_not_duplicate = $post-&gt;ID; ?&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;li&gt;&lt;a title=&quot;&lt;?php the_title(); ?&gt;&quot; href=&quot;&lt;?php the_permalink(); ?&gt;&quot;&gt;&lt;?php the_title(); ?&gt;&lt;/a&gt;&lt;/li&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;?php endwhile;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo &quot;&lt;/ul&gt;\n&quot;;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br />
&nbsp;&nbsp;&nbsp;}<br />
&nbsp;&nbsp;&nbsp;echo &quot;&lt;/ul&gt;&quot;;</p></blockquote>
<p>This last part creates another nesting with all of the posts for each category using <a href="http://codex.wordpress.org/Function_Reference/WP_Query">WP_Query</a>. The posts are displayed with their title and permalinks. Then everything is closed up and all the unordered lists are given end tags.</p>
<p>Overall I am pleased with my results and how it turned out in terms of giving the user a clear way to look through older posts by category and view all posts as a whole.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.thatphpgirl.com/a-custom-wordpress-blog-archives-page/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Changing your WordPress URL (Fantastico Install)</title>
		<link>http://www.thatphpgirl.com/changing-your-wordpress-url-fantastico-install/</link>
		<comments>http://www.thatphpgirl.com/changing-your-wordpress-url-fantastico-install/#comments</comments>
		<pubDate>Fri, 10 Jul 2009 02:04:17 +0000</pubDate>
		<dc:creator>Nikole Gipps</dc:creator>
				<category><![CDATA[DIY]]></category>
		<category><![CDATA[Blog]]></category>
		<category><![CDATA[cms]]></category>
		<category><![CDATA[Fantastico]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[phpmyadmin]]></category>
		<category><![CDATA[plugins]]></category>
		<category><![CDATA[theme]]></category>
		<category><![CDATA[upgrade]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://thatphpgirl.com/?p=123</guid>
		<description><![CDATA[If you used parts of my post on Moving and Upgrading your WordPress to change your blog&#8217;s URL (if say, for example, you were trying to take a development site live with the final URL), and something still isn&#8217;t working right, check your .htaccess and wp-config.php files&#8212;especially if you installed WordPress through Fantastico. I recently [...]]]></description>
			<content:encoded><![CDATA[<p>If you used parts of my post on <a href="http://thatphpgirl.com/moving-and-upgrading-your-wordpress/">Moving and Upgrading your WordPress</a> to change your blog&#8217;s URL (if say, for example, you were trying to take a development site live with the final URL), and something still isn&#8217;t working right, check your .htaccess and wp-config.php files&mdash;especially if you installed WordPress through Fantastico.</p>
<p>I recently ran into this problem on <a href="http://www.sheandheplanweddings.com/">She &amp; He Plan Weddings</a>. I had changed the blog&#8217;s URL in phpMyAdmin, but several items were still not working (including the admin) because it was directing me back to the development URL. I checked and rechecked the WordPress settings, the database, everything. The problem was with .htaccess and wp-config.php. I didn&#8217;t install WordPress on this site&mdash;I only came in to redo the theme and make some customizations&mdash;and I&#8217;ve always used a fresh WordPress.org install instead of using host-based installers.</p>
<p>The first problem was with .htaccess. Somehow the .htaccess file became unwritable (whether it was intentional by the blog installer or it is some Fantastico default), and the new blog URL was not being reflected. Changing the .htaccess file from this:</p>
<blockquote><p># BEGIN WordPress<br />
&lt;IfModule mod_rewrite.c&gt;<br />
RewriteEngine On<br />
RewriteBase /~ciaraine/<br />
RewriteCond %{REQUEST_FILENAME} !-f<br />
RewriteCond %{REQUEST_FILENAME} !-d<br />
RewriteRule . /~ciaraine/index.php [L]<br />
&lt;/IfModule&gt;</p>
<p># END WordPress</p>
</blockquote>
<p>to this:</p>
<blockquote><p># BEGIN WordPress<br />
&lt;IfModule mod_rewrite.c&gt;<br />
RewriteEngine On<br />
RewriteBase /<br />
RewriteCond %{REQUEST_FILENAME} !-f<br />
RewriteCond %{REQUEST_FILENAME} !-d<br />
RewriteRule . /index.php [L]<br />
&lt;/IfModule&gt;</p>
<p># END WordPress</p>
<p></code></p>
<p>solved that problem entirely. If you'll see, the first one was assuming the site's URL should be http://gator872.hostgator.com/~ciaraine/, as it was in development. The second one reflects the removal of the directory, as the final site appeared to be at a root level at <a href="http://www.sheandheplanweddings.com/">http://www.sheandheplanweddings.com/</a>.</p>
<p>For more information (and to prevent problems for yourself), <a href="http://codex.wordpress.org/Changing_File_Permissions">WordPress has this guide on how to make your files have the correct permissions</a>. If you want to leave the .htaccess file unwritable, you'll have to use the method I have outlined here.</p>
<p>The second problem was with the wp-config.php file, which is located in the root folder of your WordPress install. A Fantastico install includes this line:</p>
<blockquote><p>define('WP_SITEURL', 'http://your-url-here.com');</p>
</blockquote>
<p>that I have never seen on a self-installed WordPress installation. (Just to be sure, I <a href="http://wordpress.org/download/">downloaded the new WordPress 2.8.1</a> and checked the wp-config-sample.php file&mdash;and no, it's not in there.) This line, again, was forcing the URL to be the original http://gator872.hostgator.com/~ciaraine/ instead of the new <a href="http://www.sheandheplanweddings.com/">http://www.sheandheplanweddings.com/</a>. I set this element to read</p>
<blockquote><p>define('WP_SITEURL', 'http://www.sheandheplanweddings.com');</p>
</blockquote>
<p>but I probably could have just deleted out the line entirely as well.</p>
<p>I hope this post saves someone else from the hassle I just went through trying to push this site live. I think the whole experience also reinforced my habit of doing things &quot;the long way&quot; (by downloading WordPress and installing it myself) instead of relying on one-click installers like Fantastico. While these sort of things are good for those who are unfamiliar with installing software or for saving time, I think there is value into knowing every setting going into your install by doing it yourself.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.thatphpgirl.com/changing-your-wordpress-url-fantastico-install/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Moving and Upgrading your WordPress</title>
		<link>http://www.thatphpgirl.com/moving-and-upgrading-your-wordpress/</link>
		<comments>http://www.thatphpgirl.com/moving-and-upgrading-your-wordpress/#comments</comments>
		<pubDate>Wed, 24 Jun 2009 05:34:13 +0000</pubDate>
		<dc:creator>Nikole Gipps</dc:creator>
				<category><![CDATA[DIY]]></category>
		<category><![CDATA[Blog]]></category>
		<category><![CDATA[cms]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[phpmyadmin]]></category>
		<category><![CDATA[plugins]]></category>
		<category><![CDATA[theme]]></category>
		<category><![CDATA[upgrade]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://thatphpgirl.com/?p=103</guid>
		<description><![CDATA[Note: This post assumes you are using the self-installed WordPress on a Linux-based server running MySQL and phpMyAdmin. It also assumes that all your current plugins and your current theme is compatible with the latest version of WordPress. Please read through all of these instructions and make sure you know what they mean before you [...]]]></description>
			<content:encoded><![CDATA[<p><i>Note: This post assumes you are using the self-installed WordPress on a Linux-based server running MySQL and phpMyAdmin. It also assumes that all your current plugins and your current theme is compatible with the latest version of WordPress.</i></p>
<p>Please read through all of these instructions and make sure you know what they mean before you begin. Backing up your site and database before any transfer is always a wise move.</p>
<h2>Step 1: Download your Database</h2>
<p>Log into your database through phpMyAdmin and go to the Export tab. Use these values for your export:</p>
<ul>
<li>Export ALL TABLES in SQL format.</li>
<li>Check STRUCTURE, and then &quot;Add IF NOT EXISTS&quot;, &quot;Add AUTO_INCREMENT value&quot;, and &quot;Enclose table and field names with backquotes&quot;.</li>
<li>Check DATA and then &quot;Complete inserts&quot;, &quot;Extended inserts&quot;, &quot;Use hexadecimal for BLOB&quot;, and &quot;Export type INSERT&quot;.</li>
<li>Check SAVE AS FILE and save to your hard drive.</li>
</ul>
<h2>Step 2: Download your Current Site</h2>
<p>FTP to your current site and download the following items:</p>
<ul>
<li>The folder WP-CONTENT.</li>
<li>The file WP-CONFIG.PHP.</li>
<li>Any files or folders you may have added outside the WordPress structure, like a CSS or IMAGES directory.</li>
</ul>
<h2>Step 3: Upload your New WordPress</h2>
<p>For a general discussion of installing WordPress, see the <a href="http://codex.wordpress.org/Installing_WordPress#Famous_5-Minute_Install">5-minute Installation Guide at WordPress.org</a>. For this, you will be doing things a bit differently because you are transferring a blog, not just installing a new one.</p>
<ol>
<li><a href="http://wordpress.org/download/">Download the latest version of WordPress</a>. Unpack the files and upload everything but the WP-CONFIG-SAMPLE.PHP file to your new server.</li>
<li>Upload your old custom theme (in the WP-CONTENT folder you downloaded earlier) and any images/css/etc you may have had outside the WordPress folder structure at your old site.</li>
<li>Open the new WP-CONFIG-SAMPLE.PHP file and your old WP-CONFIG.PHP file. You will be modifying the WP-CONFIG-SAMPLE.PHP file. Follow the instructions in the file to get your <a href="https://api.wordpress.org/secret-key/1.1/">Secret API Key</a>. Then use the information in your old WP-CONFIG.PHP for the database and username, and get the hostname from your new host. Save this WP-CONFIG-SAMPLE.PHP file on your hard drive, rename it to WP-CONFIG.PHP and upload it to your new server at the root file level. (See below for additional notes on the WP-CONFIG.PHP file and changes you may have to make to it.)</li>
<li>Hold off on uploading your existing plugins until you are sure your upgrade installation is working.</li>
</ol>
<h2>Step 4: Set Up your New Database</h2>
<p>Log into the phMyAdmin on your new host, click on the Import tab, and Import the SQL file you downloaded in step 1. If for some reason you can&#8217;t use the original database and/or username, make sure you put the new database and/or username in your WP-CONFIG.PHP file on your new server. If you have changed your base URL, see the special instructions below before proceeding on to step 5.</p>
<h2>Step 5: Install and Upgrade your Database</h2>
<p>Go to the install URL on your new site, http://example.com/wp-admin/install.php for example, and follow the instructions to install WordPress and upgrade the database (if needed/prompted to do so).</p>
<h2>Step 6: Add Plugins</h2>
<p>If you had plugins originally installed, and your site is now working, you can upload the plugins in your original WP-CONTENT/PLUGINS folder back to the new site. Once they are uploaded, the WP-ADMIN will tell you if there are updates available for these plugins before you enable them.</p>
<h2>Special Step: If You Changed the URL</h2>
<p>If you have changed the site URL, or you&#8217;ve gone from a temporary URL (such as http://hostname.com/~your_account/) to your permanent URL (http://www.your_domain.com), you will need to follow this additional instruction between steps 4 and 5 above:</p>
<ol>
<li>Log in to phpMyAdmin and click on the SQL tab.</li>
<li>Enter the following code into the SQL window<br />
<blockquote><p>
UPDATE wp_options SET option_value = &#8216;http://new-url.com&#8217; WHERE option_name = &#8216;home&#8217;;<br />
UPDATE wp_options SET option_value = &#8216;http://new-url.com&#8217; WHERE option_name = &#8216;siteurl&#8217;;<br />
UPDATE wp_posts SET guid = replace(guid, &#8216;http://old-url.com&#8217;,'http://new-url.com&#8217;);<br />
UPDATE wp_posts SET post_content = replace(post_content, &#8216;http://old-url.com&#8217;, &#8216;http://new-url.com&#8217;);
</p></blockquote>
<p>replacing &quot;http://new-url.com&quot; with your new URL, &quot;http://old-url.com&quot; with your old URL, and wp_ (as in wp_posts, wp_options) with your table prefix. (The default on WordPress is wp_ but you may have changed it on your previous installation. If your default is not wp_ in your tables, you&#8217;ll also make sure this table prefix is reflected in your new WP-CONFIG.PHP file and re-upload before proceeding to step 5.)</li>
</ol>
<p>And there you have it! If you need additional assistance or your custom theme needs to be updated to work with the newest version of WordPress, consider <a href="http://thatphpgirl.com">hiring That PHP Girl</a>!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.thatphpgirl.com/moving-and-upgrading-your-wordpress/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

