<?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>New2WP</title> <atom:link href="http://new2wp.com/feed/" rel="self" type="application/rss+xml" /><link>http://new2wp.com</link> <description>Wordpress Tips for Noobs, Rookies and Pros</description> <lastBuildDate>Sun, 22 Aug 2010 13:00:50 +0000</lastBuildDate> <language>en</language> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <generator>http://wordpress.org/?v=3.0.1</generator> <item><title>[Guest Post] Submit WordPress Posts From The Frontend Of Your Site</title><link>http://new2wp.com/rookie/new-post-form-wordpress-custom-post-types/</link> <comments>http://new2wp.com/rookie/new-post-form-wordpress-custom-post-types/#comments</comments> <pubDate>Sun, 22 Aug 2010 13:00:50 +0000</pubDate> <dc:creator>Jared</dc:creator> <category><![CDATA[Featured]]></category> <category><![CDATA[Rookie]]></category> <category><![CDATA[Custom Post Form]]></category> <category><![CDATA[Guest Post]]></category> <category><![CDATA[Post types]]></category> <category><![CDATA[wp3.0]]></category><guid
isPermaLink="false">http://new2wp.com/?p=2566</guid> <description><![CDATA[This is a guest post on <a
href="http://wpshout.com">WPShout</a> .com that shows an easy way to create a custom new post submit form for the front-end of your site.It is my first guest post, but it's not one you'd want to miss. ]]></description> <content:encoded><![CDATA[<h2><a
href="http://wpshout.com/WordPress-submit-posts-from-frontend/">Create a Custom Post Type Submit Form</a></h2><p><a
href="http://wpshout.com/WordPress-submit-posts-from-frontend/">My post</a> shows a simplified method for developing a basic post form, without the need for any plugins or additional things, which you can embed in a custom page template or anything else you might want to do on your site with a custom post form.</p><p>Great for user generated content sites where your users can submit new posts from the front-end of the site, kind of like Twitter or Facebook.</p><p>It works for posting custom post type posts, as well as, for using custom taxonomies if you want, too.</p><p>As my first guest post anywhere by my own personal sites, I wanted to write something that was unique and not posted a million times slightly different. Not one of the <a
href="http://new2wp.com/featured/12-most-common-WordPress-posts/">12 most posted WordPress post topics</a>. Given that, it might possibly show you something you haven't seen already.</p><h2 align="center"><a
href="http://wpshout.com/WordPress-submit-posts-from-frontend/">Click Here To Go To The Tutorial</a></h2><p>Feel free to comment with any questions, either here or on WPShout. I'm curious what people think of my first guest post.</p><div
id="crp_related"><h3>Related Posts</h3><ul
class="relatedposts"><li><a
href="http://new2wp.com/featured/5-valuable-sites-to-submitshowcasevote-wordpress-only-sites/" rel="bookmark" class="crp_title">5 Valuable Sites To Submit Showcase And Vote Only WordPress Sites</a></li><li><a
href="http://new2wp.com/noob/new2tip-allow-visitors-to-search-by-category/" rel="bookmark" class="crp_title">New2Tip: Allow Visitors To Search By Category</a></li><li><a
href="http://new2wp.com/pro/basic-theme-framework-wordpress3-custom-post-type/" rel="bookmark" class="crp_title">WordPress Theme: 3.0 Basics &#8211; A Higher Starting Point For Theme Developers</a></li><li><a
href="http://new2wp.com/news/using-wordpress30-yet/" rel="bookmark" class="crp_title">Poll: Have You Started Using WordPress 3.0 Yet?</a></li><li><a
href="http://new2wp.com/rookie/create-social-bookmark-buttons/" rel="bookmark" class="crp_title">Create Your Own Social Bookmark Button Links</a></li></ul></div><p><a
href="%%postur%%" target="_blank">[Guest Post] Submit WordPress Posts From The Frontend Of Your Site</a></p><ul><li><a
href="http://twitter.com/home?status=[Guest Post] Submit WordPress Posts From The Frontend Of Your Site http://new2wp.com/rookie/new-post-form-wordpress-custom-post-types/" rel="nofollow" title="Post this on Twitter" target="_blank">Post this on Twitter</a></li><li><a
href="http://facebook.com/share.php?u=http://new2wp.com/rookie/new-post-form-wordpress-custom-post-types/&title=[Guest Post] Submit WordPress Posts From The Frontend Of Your Site" rel="nofollow" title="Post this on Facebook" target="_blank">Post this on Facebook</a></li><li><a
href="http://www.stumbleupon.com/submit?url=http://new2wp.com/rookie/new-post-form-wordpress-custom-post-types/&title=[Guest Post] Submit WordPress Posts From The Frontend Of Your Site" rel="nofollow" title="Stumble This Post">Stumble This Post</a></li><li><a
href="http://del.icio.us/post?url=http://new2wp.com/rookie/new-post-form-wordpress-custom-post-types/&title=[Guest Post] Submit WordPress Posts From The Frontend Of Your Site" rel="nofollow" title="Share this on del.icio.us" target="_blank">Share this on del.icio.us</a></li><li><a
href="http://digg.com/submit?phase=2&url=http://new2wp.com/rookie/new-post-form-wordpress-custom-post-types/&title=[Guest Post] Submit WordPress Posts From The Frontend Of Your Site" rel="nofollow" title="Digg This Post" target="_blank">Digg This Post</a></li><li><a
href="http://thewebblend.com/submit?url=http://new2wp.com/rookie/new-post-form-wordpress-custom-post-types/&title=[Guest Post] Submit WordPress Posts From The Frontend Of Your Site" rel="nofollow" title="Blend This!" target="_blank">Blend This!</a></li><li><a
href="http://designbump.com/submit?url=http://new2wp.com/rookie/new-post-form-wordpress-custom-post-types/&title=[Guest Post] Submit WordPress Posts From The Frontend Of Your Site" rel="nofollow" title="DesignBump This" target="_blank">DesignBump This</a></li><li><a
href="http://www.designfloat.com/submit.php?url=http://new2wp.com/rookie/new-post-form-wordpress-custom-post-types/&title=[Guest Post] Submit WordPress Posts From The Frontend Of Your Site" rel="nofollow" title="Post this on DesignFloat" target="_blank">Post this on DesignFloat</a></li></ul><p><a
href="http://new2wp.com"><img
src="http://tweeaks.com/wp-content/uploads/2010/08/new2wp-468x60px1.png" alt="New2WP" /></a></p><p><small>Copyright ©2010 <a
href="http://new2wp.com">New2WP.com</a>. Posted by jaredwilli on 2010 |<a
href="http://new2wp.com/rookie/new-post-form-wordpress-custom-post-types/">Permalink</a></p>]]></content:encoded> <wfw:commentRss>http://new2wp.com/rookie/new-post-form-wordpress-custom-post-types/feed/</wfw:commentRss> <slash:comments>2</slash:comments> </item> <item><title>363 Vibrant Color Swatches For Photoshop Download Pack</title><link>http://new2wp.com/featured/363-photoshop-color-swatches-download/</link> <comments>http://new2wp.com/featured/363-photoshop-color-swatches-download/#comments</comments> <pubDate>Sat, 21 Aug 2010 11:04:52 +0000</pubDate> <dc:creator>Jared</dc:creator> <category><![CDATA[Featured]]></category> <category><![CDATA[Site News]]></category> <category><![CDATA[Design]]></category> <category><![CDATA[Downloads]]></category> <category><![CDATA[Photoshop]]></category> <category><![CDATA[Resources]]></category><guid
isPermaLink="false">http://new2wp.com/?p=2548</guid> <description><![CDATA[This is the result of me grabbing colors from things I like the color of, which led to me taking multi-colored patterns and gradients and adjusting the hue/saturation, blending mode, and opacity of them over and over grabbing all the colors of it after each change.]]></description> <content:encoded><![CDATA[<h2>DarkSide of the Sun Palette</h2><p>Needless to say, I spent the better part of my day yesterday grabbing colors from everything and the same things with different color adjustments applied to alter the colors of them. It was not something I planned on doing, but have needed to do for a long time.</p><p>This palette of swatches is more than I need to do what I need to do currently. Plus it goes well with the 50 pack of smooth gradients I made not long ago which <a
href="/downloads/">you can download here</a> by the way. Hope this color pack helps you make some cool designs! (pay no attention to my misspelling of palette on the image :P)<br
/> <a
href="http://new2wp.com/labs/downloads/Darkside-of-the-Sun-Swatch-Pallete_New2WP.zip" rel="download"><img
src="http://new2wp.com/wp-content/uploads/2010/08/Darkside-of-the-Sun_pallete-New2WP.png" alt="Darkside-of-the-Sun_pallete-New2WP" title="Darkside-of-the-Sun_pallete-New2WP" width="399" height="181" class="aligncenter size-full wp-image-2547" /></a></p><h3 align="center"><a
href="http://new2wp.com/labs/downloads/Darkside-of-the-Sun-Swatch-Pallete_New2WP.zip">Click here to download this swatch pack</a></h3><div
align="center"><a
href="/downloads/">View more downloads...</a></div><p><a
href="https://www.e-junkie.com/ecom/gb.php?cl=12635&amp;c=ib&amp;aff=81542" target="ejejcsingle"><img
src="http://new2wp.com/wp-content/uploads/2010/06/WProckstar_468x60.jpg" alt="WProckstar" title="WProckstar" class="aligncenter size-full wp-image-1691"></a></p><div
id="crp_related"><h3>Related Posts</h3><ul
class="relatedposts"><li><a
href="http://new2wp.com/news/50-free-smooth-photoshop-gradients/" rel="bookmark" class="crp_title">50 Free Smooth Photoshop Gradients</a></li><li><a
href="http://new2wp.com/noob/wordpress-plugin-new2wp-author-box-version-1-0/" rel="bookmark" class="crp_title">WordPress Plugin: New2WP Author Box Version 1.0</a></li><li><a
href="http://new2wp.com/news/new2you-drawing-canvas-with-11-brushes-and-color-picker/" rel="bookmark" class="crp_title">New2You: Drawing Canvas With 11 Brushes And Color Picker</a></li><li><a
href="http://new2wp.com/noob/advertise-on-new2wp/" rel="bookmark" class="crp_title">Advertise On New2WP</a></li><li><a
href="http://new2wp.com/noob/how-to-make-css3-buttons/" rel="bookmark" class="crp_title">How To Make Two Tone CSS 3 Inset Buttons</a></li></ul></div><p><a
href="%%postur%%" target="_blank">363 Vibrant Color Swatches For Photoshop Download Pack</a></p><ul><li><a
href="http://twitter.com/home?status=363 Vibrant Color Swatches For Photoshop Download Pack http://new2wp.com/featured/363-photoshop-color-swatches-download/" rel="nofollow" title="Post this on Twitter" target="_blank">Post this on Twitter</a></li><li><a
href="http://facebook.com/share.php?u=http://new2wp.com/featured/363-photoshop-color-swatches-download/&title=363 Vibrant Color Swatches For Photoshop Download Pack" rel="nofollow" title="Post this on Facebook" target="_blank">Post this on Facebook</a></li><li><a
href="http://www.stumbleupon.com/submit?url=http://new2wp.com/featured/363-photoshop-color-swatches-download/&title=363 Vibrant Color Swatches For Photoshop Download Pack" rel="nofollow" title="Stumble This Post">Stumble This Post</a></li><li><a
href="http://del.icio.us/post?url=http://new2wp.com/featured/363-photoshop-color-swatches-download/&title=363 Vibrant Color Swatches For Photoshop Download Pack" rel="nofollow" title="Share this on del.icio.us" target="_blank">Share this on del.icio.us</a></li><li><a
href="http://digg.com/submit?phase=2&url=http://new2wp.com/featured/363-photoshop-color-swatches-download/&title=363 Vibrant Color Swatches For Photoshop Download Pack" rel="nofollow" title="Digg This Post" target="_blank">Digg This Post</a></li><li><a
href="http://thewebblend.com/submit?url=http://new2wp.com/featured/363-photoshop-color-swatches-download/&title=363 Vibrant Color Swatches For Photoshop Download Pack" rel="nofollow" title="Blend This!" target="_blank">Blend This!</a></li><li><a
href="http://designbump.com/submit?url=http://new2wp.com/featured/363-photoshop-color-swatches-download/&title=363 Vibrant Color Swatches For Photoshop Download Pack" rel="nofollow" title="DesignBump This" target="_blank">DesignBump This</a></li><li><a
href="http://www.designfloat.com/submit.php?url=http://new2wp.com/featured/363-photoshop-color-swatches-download/&title=363 Vibrant Color Swatches For Photoshop Download Pack" rel="nofollow" title="Post this on DesignFloat" target="_blank">Post this on DesignFloat</a></li></ul><p><a
href="http://new2wp.com"><img
src="http://tweeaks.com/wp-content/uploads/2010/08/new2wp-468x60px1.png" alt="New2WP" /></a></p><p><small>Copyright ©2010 <a
href="http://new2wp.com">New2WP.com</a>. Posted by jaredwilli on 2010 |<a
href="http://new2wp.com/featured/363-photoshop-color-swatches-download/">Permalink</a></p>]]></content:encoded> <wfw:commentRss>http://new2wp.com/featured/363-photoshop-color-swatches-download/feed/</wfw:commentRss> <slash:comments>4</slash:comments> </item> <item><title>OOPost Types: Objects Part 3 &#8211; Object Oriented WordPress 3.0 App</title><link>http://new2wp.com/pro/wordpress-custom-post-types-object-oriented-series3/</link> <comments>http://new2wp.com/pro/wordpress-custom-post-types-object-oriented-series3/#comments</comments> <pubDate>Tue, 10 Aug 2010 12:00:35 +0000</pubDate> <dc:creator>Jared</dc:creator> <category><![CDATA[Featured]]></category> <category><![CDATA[Pro]]></category> <category><![CDATA[Objects]]></category> <category><![CDATA[OOP]]></category> <category><![CDATA[Post types]]></category> <category><![CDATA[Tutorials]]></category> <category><![CDATA[wp3.0]]></category><guid
isPermaLink="false">http://new2wp.com/?p=2004</guid> <description><![CDATA[If you've been following along you now know how to create a class and custom post types. The next step is to use it to display the posts on your site as a custom page.Learn how to create new objects of your post type class using a custom page template in WordPress.]]></description> <content:encoded><![CDATA[<h2>Time To Make Some Magic Happen</h2><p>Continuing where we left of in <a
href="http://new2wp.com/pro/WordPress-custom-post-types-object-oriented-series2/">part 2 of OOPost Types</a> where we finished building a Php class for setting up methods that our Sites custom post type will use, we now need to put all that code to use.</p><p>If you haven't yet read either one of the previous tutorials, you may want to go back and do that before you continue. You will learn how to create the class and functions which are used in this part.</p><ul><li><a
href="http://new2wp.com/pro/WordPress-custom-post-types-object-oriented-series1/">OOPost Types: Classes Part 1 - Object Oriented WordPress 3.0 App</a></li><li><a
href="http://new2wp.com/pro/WordPress-custom-post-types-object-oriented-series2/">OOPost Types: Methods Part 2 - Object Oriented WordPress 3.0 App</a></li></ul><p>This part of the OOPost Types series will go over how to make use of the custom post type WordPress class created in the previous posts, to easily display the Sites post content on a custom page template. That means we will be instantiating the class to create an new object of it.</p><p>I've added a method to the class finished in part 2 that is what our object for showing the sites url and screenshot. If you haven't already, add this function below the meta_options() function at the bottom of the post type class.</p><pre class="brush: php;">
    public function mshot($mshotsize) {
        global $post;
        $imgWidth = $mshotsize;
        $myurl = get_post_meta($post-&gt;ID, 'siteurl', true);
		if ( $myurl != '' ) {
			$mshoturl = '';
			if ( preg_match( &quot;/http(s?):\/\//&quot;, $myurl )) {
				$siteurl = get_post_meta( $post-&gt;ID, 'siteurl', true );
				$mshoturl = 'http://s.WordPress.com/mshots/v1/' . urlencode( $myurl );
			} else {
				$siteurl = 'http://' . get_post_meta( $post-&gt;ID, 'siteurl', true );
				$mshoturl = 'http://s.WordPress.com/mshots/v1/' . urlencode('http://'.$myurl );
			}
		}
        $mshotimg = '&lt;img src=&quot;'.$mshoturl.'?w='.$imgWidth.'&quot; alt=&quot;'.get_the_title().'&quot; title=&quot;'.get_the_title().'&quot; /&gt;';

        return array( $siteurl, $mshotimg );
	}
</pre><p>This returns an array consisting of the site url which was entered for each site, and the output of the screenshot image that is created with the use of that url.</p><h2>Creating Custom Page Template</h2><p>In order to display the content of our Sites post type, we need to either create a custom query to be used in the default WordPress theme templates, or better yet, create new custom WordPress page templates. To learn the best and most stress free way to create new custom templates you should read a previous post I wrote on <a
href="http://new2wp.com/noob/WordPress-custom-templates-the-easy-and-most-logical-method/">making custom WordPress page templates</a>.</p><p>The format mentioned in that post to create new page templates using <span
id="fixed">page-[slug].php</span>, so what we need to do for displaying the list of submitted Sites is create a new file named <span
id="fixed">page-sites.php</span>.</p><p>In order to display the information of the Site posts, we need to make a custom query which we pass to <a
href="http://codex.WordPress.org/The_Loop">the Loop</a>.</p><p>First create your page-sites.php template. You can copy and paste the code from page.php or index.php into this new file and remove the IF statement that loops through the posts. It should be something like <span
id="fixed">if( have_posts()) : while( have_posts()) : the_post();</span></p><pre class="brush: php;">
&lt;?php get_header(); ?&gt;

&lt;div id=&quot;content&quot; class=&quot;inner clearfix&quot;&gt;
	&lt;div class=&quot;post&quot; role=&quot;main&quot;&gt;

	&lt;?php // Do stuff ?&gt;

	&lt;/div&gt;&lt;!-- end .post --&gt;
&lt;/div&gt;&lt;!-- end #content --&gt;

&lt;?php get_sidebar(); ?&gt;
&lt;?php get_footer(); ?&gt;
</pre><h2>Custom Post Type Queries For The Loop</h2><p>Below is the loop which will display the sites. It first checks to see if were on the right page, and then if so it runs the code. We create an object of the class we made to display the screenshot image of the sites, which is done just with the use of the site url entered when posting. The custom loop query will be done <a
href="http://new2wp.com/noob/query_posts-wp_query-differences/">by using WP_Query()</a> to query the post_type.</p><p>I've commented the code for further explanation. Pay specific attention to the part that instantiates the custom post type class that was made in the previous posts. The <span
id="fixed">$s = new TypeSites();</span> and <span
id="fixed">$a = $s->mshot(250);</span> are important for showing the submitted site information.</p><pre class="brush: php;">
&lt;?php
	$q = new WP_query();
	$q-&gt;query( 'post_type=site' );

	/* Begin the Loop */
	if ($q-&gt;have_posts()) :
		while ($q-&gt;have_posts()) : $q-&gt;the_post();

			/**
			 * Now instantiate the Sites class we made in posttypes.php setting the $s variable
			 * Create a new variable $a set to the value of the mshot(250) function from the class.
			 */
			$s = new TypeSites();
			$a = $s-&gt;mshot(250);

			/**
			 * Output the content of the Site posts
			 */
			?&gt;

			&lt;div id=&quot;site-&lt;?php the_ID(); ?&gt;&quot; class=&quot;sites clearfix user_id_&lt;?php the_author_ID(); ?&gt;&quot;&gt;
				&lt;div class=&quot;site-thumbnail&quot;&gt;
					&lt;a href=&quot;&lt;?php the_permalink(); ?&gt;&quot; title=&quot;&lt;?php the_title(); ?&gt;&quot;&gt;
						&lt;?php
						/**
						 * Here we echo out the value of the $a which is an array.
						 * The [1] will retreive the 2nd value of mshot() which returns the
						 * site thumbnai image which is generated by the Url entered in the post.
						 */
						 echo $a[1];
						 ?&gt;
					&lt;/a&gt;
				&lt;/div&gt;

				&lt;h2 class=&quot;site-title&quot;&gt;&lt;a href=&quot;&lt;?php the_permalink(); ?&gt;&quot;&gt;&lt;?php the_title();?&gt;&lt;/a&gt;&lt;/h2&gt;
				&lt;div class=&quot;meta&quot;&gt;
					&lt;?php __( 'Added by: '. the_author_posts_link() .' on '. the_time( &quot;F j&quot; ) .' | '. comments_popup_link( __( &quot;0 Comments&quot; ), __( &quot;1 Comment&quot; ), __( &quot;% Comments&quot; ) ); ?&gt;
				&lt;/div&gt;

				&lt;div class=&quot;entry&quot;&gt;
					&lt;?php the_content( __( '(More ...)' )); ?&gt;
				&lt;/div&gt;
				&lt;div class=&quot;fl post-tags&quot;&gt;&lt;?php the_tags( __( ' ' ), ' , ', ' ' ); ?&gt;&lt;/div&gt;
				&lt;div class=&quot;fr edit-link&quot;&gt;&lt;?php edit_post_link( __( 'Edit' ) ); ?&gt;&lt;/div&gt;
			&lt;/div&gt;

		&lt;?php endwhile; ?&gt;

		&lt;?php if( function_exists( 'wp_pagenavi' )) { wp_pagenavi(); } else { ?&gt;
			&lt;div class=&quot;navigation clearfix&quot;&gt;
				&lt;div class=&quot;alignleft&quot;&gt;&lt;?php next_posts_link('&amp;laquo; Previous Entries'); ?&gt;&lt;/div&gt;
				&lt;div class=&quot;alignright&quot;&gt;&lt;?php previous_posts_link('Next Entries &amp;raquo;'); ?&gt;&lt;/div&gt;
			&lt;/div&gt;
		&lt;?php } ?&gt;

&lt;?php endif; ?&gt;
</pre><h2>Make A Custom Single Template</h2><p>We also need to create a new custom single post template which is what will display the single posts for the Sites. So also create a new file named <span
id="fixed">single-site.php</span>. You might remember the reference to single-site.php was made in the template redirect function we made in the class. If you neglected to create this single template, then later down the line you might find yourself getting a Php error saying that it does not exist.</p><p>So create another new file named single-site.php and use this code for the Loop.</p><pre class="brush: php;">
	&lt;?php if (have_posts()) : while (have_posts()) : the_post(); ?&gt;
	&lt;?php $s = new TypeSites();
	$a = $s-&gt;mshot(600);
	?&gt;

	&lt;div id=&quot;site-&lt;?php the_ID(); ?&gt;&quot; class=&quot;user_id_&lt;?php the_author_ID(); ?&gt;&quot;&gt;
		&lt;h2 class=&quot;post-title&quot;&gt;&lt;a href=&quot;&lt;?php echo $a[0]; ?&gt;&quot;&gt;&lt;?php the_title(); ?&gt;&lt;/a&gt;&lt;/h2&gt;
		&lt;div class=&quot;meta&quot;&gt;
			Added by: &lt;?php the_author_posts_link(); ?&gt; on &lt;?php the_time(&quot;F j&quot;); ?&gt; |
			&lt;?php comments_popup_link( __( '0 Comments' ), __( '1 Comment' ), __( '% Comments' )); ?&gt;
		&lt;/div&gt;

		&lt;div class=&quot;entry&quot;&gt;
			&lt;?php the_content( __( '(More ...)' )); ?&gt;
			&lt;div class=&quot;fl post-tags&quot;&gt;&lt;?php the_tags( __( ' ' ), ' , ', ' ' ); ?&gt;&lt;/div&gt;
			&lt;div class=&quot;fr edit-link&quot;&gt;&lt;?php edit_post_link( __( 'Edit' ) ); ?&gt;&lt;/div&gt;
			&lt;div class=&quot;site-bigthumb&quot; align=&quot;center&quot;&gt;
				&lt;a href=&quot;&lt;?php echo $a[0]; ?&gt;&quot; title=&quot;&lt;?php the_title(); ?&gt;&quot;&gt;
					&lt;?php echo $a[1]; ?&gt;
				&lt;/a&gt;
			&lt;/div&gt;
		&lt;/div&gt;
	&lt;/div&gt;

	&lt;?php endwhile; ?&gt;
	&lt;?php endif; ?&gt;
</pre><p>This is all you need to display your custom post types in WordPress. This is more specifically used for the particular post type we've set up using the class, but you can use this same idea to display custom post types that are not created using a class as well.</p><h2>Full page-sites.php Code</h2><pre class="brush: php;">
&lt;?php get_header(); ?&gt;

&lt;div id=&quot;content&quot; class=&quot;inner clearfix&quot;&gt;
	&lt;div class=&quot;post&quot; role=&quot;main&quot;&gt;

	$q = new WP_query();
	$q-&gt;query( 'post_type=site' );

	/* Begin the Loop */
	if ($q-&gt;have_posts()) :
		while ($q-&gt;have_posts()) : $q-&gt;the_post();

			/**
			 * Now instantiate the Sites class we made in posttypes.php setting the $s variable
			 * Create a new variable $a set to the value of the mshot(250) function from the class.
			 */
			$s = new TypeSites();
			$a = $s-&gt;mshot(250);

			/**
			 * Output the content of the Site posts
			 */
			?&gt;

			&lt;div id=&quot;site-&lt;?php the_ID(); ?&gt;&quot; class=&quot;sites clearfix user_id_&lt;?php the_author_ID(); ?&gt;&quot;&gt;
				&lt;div class=&quot;site-thumbnail&quot;&gt;
					&lt;a href=&quot;&lt;?php the_permalink(); ?&gt;&quot; title=&quot;&lt;?php the_title(); ?&gt;&quot;&gt;
						&lt;?php
						/**
						 * Here we echo out the value of the $a which is an array.
						 * The [1] will retreive the 2nd value of mshot() which returns the
						 * site thumbnai image which is generated by the Url entered in the post.
						 */
						 echo $a[1];
						 ?&gt;
					&lt;/a&gt;
				&lt;/div&gt;

				&lt;h2 class=&quot;site-title&quot;&gt;&lt;a href=&quot;&lt;?php the_permalink(); ?&gt;&quot;&gt;&lt;?php the_title();?&gt;&lt;/a&gt;&lt;/h2&gt;
				&lt;div class=&quot;meta&quot;&gt;
					&lt;?php __( 'Added by: '. the_author_posts_link() .' on '. the_time( &quot;F j&quot; ) .' | '. comments_popup_link( __( &quot;0 Comments&quot; ), __( &quot;1 Comment&quot; ), __( &quot;% Comments&quot; ) ); ?&gt;
				&lt;/div&gt;

				&lt;div class=&quot;entry&quot;&gt;
					&lt;?php the_content( __( '(More ...)' )); ?&gt;
				&lt;/div&gt;
				&lt;div class=&quot;fl post-tags&quot;&gt;&lt;?php the_tags( __( ' ' ), ' , ', ' ' ); ?&gt;&lt;/div&gt;
				&lt;div class=&quot;fr edit-link&quot;&gt;&lt;?php edit_post_link( __( 'Edit' ) ); ?&gt;&lt;/div&gt;
			&lt;/div&gt;

		&lt;?php endwhile; ?&gt;

		&lt;?php if( function_exists( 'wp_pagenavi' )) { wp_pagenavi(); } else { ?&gt;
			&lt;div class=&quot;navigation clearfix&quot;&gt;
				&lt;div class=&quot;alignleft&quot;&gt;&lt;?php next_posts_link('&amp;laquo; Previous Entries'); ?&gt;&lt;/div&gt;
				&lt;div class=&quot;alignright&quot;&gt;&lt;?php previous_posts_link('Next Entries &amp;raquo;'); ?&gt;&lt;/div&gt;
			&lt;/div&gt;
		&lt;?php } ?&gt;

&lt;?php endif; ?&gt;

	&lt;/div&gt;&lt;!-- end .post --&gt;
&lt;/div&gt;&lt;!-- end #content --&gt;

&lt;?php get_sidebar(); ?&gt;
&lt;?php get_footer(); ?&gt;
</pre><h2>Full single-site.php Code</h2><pre class="brush: php;">
&lt;?php get_header(); ?&gt;

&lt;div id=&quot;content&quot; class=&quot;inner clearfix&quot;&gt;
	&lt;div class=&quot;post&quot; role=&quot;main&quot;&gt;

	&lt;?php if (have_posts()) : while (have_posts()) : the_post(); ?&gt;
	&lt;?php $s = new TypeSites();
	$a = $s-&gt;mshot(600);
	?&gt;

	&lt;div id=&quot;site-&lt;?php the_ID(); ?&gt;&quot; class=&quot;user_id_&lt;?php the_author_ID(); ?&gt;&quot;&gt;
		&lt;h2 class=&quot;post-title&quot;&gt;&lt;a href=&quot;&lt;?php echo $a[0]; ?&gt;&quot;&gt;&lt;?php the_title(); ?&gt;&lt;/a&gt;&lt;/h2&gt;
		&lt;div class=&quot;meta&quot;&gt;
			Added by: &lt;?php the_author_posts_link(); ?&gt; on &lt;?php the_time(&quot;F j&quot;); ?&gt; |
			&lt;?php comments_popup_link( __( '0 Comments' ), __( '1 Comment' ), __( '% Comments' )); ?&gt;
		&lt;/div&gt;

		&lt;div class=&quot;entry&quot;&gt;
			&lt;?php the_content( __( '(More ...)' )); ?&gt;
			&lt;div class=&quot;fl post-tags&quot;&gt;&lt;?php the_tags( __( ' ' ), ' , ', ' ' ); ?&gt;&lt;/div&gt;
			&lt;div class=&quot;fr edit-link&quot;&gt;&lt;?php edit_post_link( __( 'Edit' ) ); ?&gt;&lt;/div&gt;
			&lt;div class=&quot;site-bigthumb&quot; align=&quot;center&quot;&gt;
				&lt;a href=&quot;&lt;?php echo $a[0]; ?&gt;&quot; title=&quot;&lt;?php the_title(); ?&gt;&quot;&gt;
					&lt;?php echo $a[1]; ?&gt;
				&lt;/a&gt;
			&lt;/div&gt;
		&lt;/div&gt;
	&lt;/div&gt;

	&lt;?php endwhile; ?&gt;
	&lt;?php endif; ?&gt;

	&lt;/div&gt;&lt;!-- end .post --&gt;
&lt;/div&gt;&lt;!-- end #content --&gt;

&lt;?php get_sidebar(); ?&gt;
&lt;?php get_footer(); ?&gt;
</pre><p>If you have any questions on this let me know in the comments below. Also, let me know if there are any errors in my code. I have tested this, and it does work for me but based on the last post there may be issues for other people that I was not aware of.</p><div
class="postprev"><a
href="/pro/WordPress-custom-post-types-object-oriented-series2">&laquo; Part 2</a></div><div
class="postnext"><a
href="/pro/WordPress-custom-post-types-object-oriented-series4#">Soon, Part 4 &raquo;</a></div><div
id="crp_related"><h3>Related Posts</h3><ul
class="relatedposts"><li><a
href="http://new2wp.com/noob/new2tip-allow-visitors-to-search-by-category/" rel="bookmark" class="crp_title">New2Tip: Allow Visitors To Search By Category</a></li><li><a
href="http://new2wp.com/rookie/create-social-bookmark-buttons/" rel="bookmark" class="crp_title">Create Your Own Social Bookmark Button Links</a></li><li><a
href="http://new2wp.com/pro/wordpress-custom-post-types-object-oriented-series2/" rel="bookmark" class="crp_title">OOPost Types: Methods Part 2 &#8211; Object Oriented WordPress 3.0 App</a></li><li><a
href="http://new2wp.com/noob/adding-backwards-compatible-wordpress-menus-to-your-theme/" rel="bookmark" class="crp_title">Adding Backwards Compatible WordPress Menus To Your Theme</a></li><li><a
href="http://new2wp.com/noob/how-to-remove-nofollow-from-your-comments/" rel="bookmark" class="crp_title">How To Remove nofollow From Your Comments</a></li></ul></div><p><a
href="%%postur%%" target="_blank">OOPost Types: Objects Part 3 &#8211; Object Oriented WordPress 3.0 App</a></p><ul><li><a
href="http://twitter.com/home?status=OOPost Types: Objects Part 3 &#8211; Object Oriented WordPress 3.0 App http://new2wp.com/pro/wordpress-custom-post-types-object-oriented-series3/" rel="nofollow" title="Post this on Twitter" target="_blank">Post this on Twitter</a></li><li><a
href="http://facebook.com/share.php?u=http://new2wp.com/pro/wordpress-custom-post-types-object-oriented-series3/&title=OOPost Types: Objects Part 3 &#8211; Object Oriented WordPress 3.0 App" rel="nofollow" title="Post this on Facebook" target="_blank">Post this on Facebook</a></li><li><a
href="http://www.stumbleupon.com/submit?url=http://new2wp.com/pro/wordpress-custom-post-types-object-oriented-series3/&title=OOPost Types: Objects Part 3 &#8211; Object Oriented WordPress 3.0 App" rel="nofollow" title="Stumble This Post">Stumble This Post</a></li><li><a
href="http://del.icio.us/post?url=http://new2wp.com/pro/wordpress-custom-post-types-object-oriented-series3/&title=OOPost Types: Objects Part 3 &#8211; Object Oriented WordPress 3.0 App" rel="nofollow" title="Share this on del.icio.us" target="_blank">Share this on del.icio.us</a></li><li><a
href="http://digg.com/submit?phase=2&url=http://new2wp.com/pro/wordpress-custom-post-types-object-oriented-series3/&title=OOPost Types: Objects Part 3 &#8211; Object Oriented WordPress 3.0 App" rel="nofollow" title="Digg This Post" target="_blank">Digg This Post</a></li><li><a
href="http://thewebblend.com/submit?url=http://new2wp.com/pro/wordpress-custom-post-types-object-oriented-series3/&title=OOPost Types: Objects Part 3 &#8211; Object Oriented WordPress 3.0 App" rel="nofollow" title="Blend This!" target="_blank">Blend This!</a></li><li><a
href="http://designbump.com/submit?url=http://new2wp.com/pro/wordpress-custom-post-types-object-oriented-series3/&title=OOPost Types: Objects Part 3 &#8211; Object Oriented WordPress 3.0 App" rel="nofollow" title="DesignBump This" target="_blank">DesignBump This</a></li><li><a
href="http://www.designfloat.com/submit.php?url=http://new2wp.com/pro/wordpress-custom-post-types-object-oriented-series3/&title=OOPost Types: Objects Part 3 &#8211; Object Oriented WordPress 3.0 App" rel="nofollow" title="Post this on DesignFloat" target="_blank">Post this on DesignFloat</a></li></ul><p><a
href="http://new2wp.com"><img
src="http://tweeaks.com/wp-content/uploads/2010/08/new2wp-468x60px1.png" alt="New2WP" /></a></p><p><small>Copyright ©2010 <a
href="http://new2wp.com">New2WP.com</a>. Posted by jaredwilli on 2010 |<a
href="http://new2wp.com/pro/wordpress-custom-post-types-object-oriented-series3/">Permalink</a></p>]]></content:encoded> <wfw:commentRss>http://new2wp.com/pro/wordpress-custom-post-types-object-oriented-series3/feed/</wfw:commentRss> <slash:comments>2</slash:comments> </item> <item><title>WordPress Theme: 3.0 Basics &#8211; A Higher Starting Point For Theme Developers</title><link>http://new2wp.com/pro/basic-theme-framework-wordpress3-custom-post-type/</link> <comments>http://new2wp.com/pro/basic-theme-framework-wordpress3-custom-post-type/#comments</comments> <pubDate>Mon, 02 Aug 2010 12:00:05 +0000</pubDate> <dc:creator>Jared</dc:creator> <category><![CDATA[Featured]]></category> <category><![CDATA[Pro]]></category> <category><![CDATA[CSS3]]></category> <category><![CDATA[Downloads]]></category> <category><![CDATA[Post types]]></category> <category><![CDATA[Taxonomies]]></category> <category><![CDATA[Themes]]></category> <category><![CDATA[wp3.0]]></category><guid
isPermaLink="false">http://new2wp.com/?p=2369</guid> <description><![CDATA[Announcing the release of a WordPress 3.0 Basic theme. This is a theme framework that has all kinds of great 3.0 features including a custom post type I made. It's a great starter theme for WP theme developers, and just as great to use as is.Check out everything included in this theme, and download it to try it out for yourself.]]></description> <content:encoded><![CDATA[<h2>Develop It Or Use As A Social Bookmarking Site</h2><p>This is a New2WP 3.0 theme framework that started out as more of a basic starter theme to use when making new WordPress themes and quickly became a bigger project than was planned. In it I have included the Sites custom post type which I wrote about in the <a
href="http://new2wp.com/pro/WordPress-custom-post-types-object-oriented-series2/">first two parts</a> of my <a
href="http://new2wp.com/pro/WordPress-custom-post-types-object-oriented-series1/">OOPost Types series</a> tutorial. With this, and many other added features make this theme truly 3.0 ready.</p><p>Well one thing led to another and it sort of became not just a theme to use as a starting point for theme developers, but it can now be used the way it is out of the box as a sort of social bookmarking type of theme. So whether you're a theme dev, or just someone looking to make a somewhat unique style WP site, you should check out <strong><a
href="http://zrz8.com">3.0 Basics</a></strong>.</p><div
align="center"><a
href="http://zrz8.com" title="3.0 Basics theme demo"><img
src="http://new2wp.com/wp-content/uploads/2010/08/3.0basics1.jpg" style="border:1px solid #182431;" /></a></div><h2>Built-In Features</h2><p>Included in this theme are numerous features that are working and functional as soon as you activate the theme, and there's tons of various functions, code customizations, CSS and CSS3 styles and jQuery scripts that will make your life easier.</p><p><strong>Custom Post Type</strong></p><ul><li>Custom post type for submitting Sites.</li><li>Custom page and single templates for Sites posts</li><li>Simple site live Site screenshots generated on the fly from the URL of a posted Site. No need to upload thumbnail images.</li></ul><p><strong>Pre-made Nav Menus</strong></p><ul><li>Pre-registered menu locations (Top, Header, Footer).</li><li>Pre-created WP nav menus to go with each registered location.</li><li>Default Home menu item for each menu. (prevents the default 'show all' if menu is empty).</li></ul><p><strong>Other Features</strong></p><ul><li>User login form in header</li><li>Custom background image</li><li>Custom dashboard styles</li><li>CSS 3 Styling</li><li>Ajax live screenshots and post thumbnails</li><li>Over 50 different useful functions</li><li>And so much more!</li></ul><p>There's way to much to list here, so you'll have to download it and see for yourself all the great things it has, and what it's capable of doing.</p><h2>Downloading 3.0 Basics</h2><p>I will be adding it to the theme repository on WordPress.org and should be downloadable soon from there. I have also made a repository for it on Github, and you can download it from there now, as well as watch or fork it if you want.</p><p><a
href="http://zrz8.com" title="Demo site for 3.0 Basics theme"><strong>View 3.0 Basics Demo Site</strong></a></p><p><a
href="http://github.com/jaredwilli/3.0basics" title="Github repository for 3.0 Basics theme"><strong>Github repository for 3.0 Basics</strong></a></p><p><a
href="http://github.com/jaredwilli/3.0basics/archives/master" title="Download 3.0 Basics from Github"><strong>Download 3.0 Basics from Github</strong></a></p><h2>3.0 Basics Theme Screenshots</h2><div
align="center" class="alignleft"> <strong>Sites Custom Post Type</strong><br
/> <img
src="http://new2wp.com/wp-content/uploads/2010/08/3.0basics4.png" style="border:1px solid #182431;" /></div><div
align="center" class="alignright"> <strong>Upload Background Images</strong><br
/> <img
src="http://new2wp.com/wp-content/uploads/2010/08/3.0basics3.png" style="border:1px solid #182431;" /></div><p><br
clear="all" /></p><div
align="center" class="alignleft"> <strong>Custom Dashboard</strong><br
/> <img
src="http://new2wp.com/wp-content/uploads/2010/08/3.0basics2.png" style="border:1px solid #182431;" /></div><div
align="center" class="alignright"> <strong>A Blog Post</strong><br
/> <img
src="http://new2wp.com/wp-content/uploads/2010/08/3.0basics5.png" style="border:1px solid #182431;" /></div><p><br
clear="all" /></p><h3>* List of Known Bugs</h3><p>This theme is not perfect of course. Here's a list of some things you may find buggy that I am working on fixing for future version releases. Please let me know of any not listed here that you come across by posting a <a
href="#respond">comment below</a>, so I can add them to this list and keep track of what needs to be done still.</p><ul><li>Site thumbnail generation doesn't work perfect</li><li>Custom columns on Sites manage posts page isn't complete</li></ul><h3>Thoughts?</h3><p>If you like this theme, be sure to recommend it, share it, tweet it, and comment below. It is still a work in progress. After all, it is a development theme. So I will be updating the repositories with new version releases.</p><p>Now that this is done, I can get back to writing part 3 of <a
href="http://new2wp.com/pro/WordPress-custom-post-types-object-oriented-series/">OOPost Types</a>. If you don't want to wait for that, I'll be finishing the makings of this themes custom post type object, so you can download this and use it now.</p><div
id="crp_related"><h3>Related Posts</h3><ul
class="relatedposts"><li><a
href="http://new2wp.com/pro/wordpress-custom-post-types-object-oriented-series1/" rel="bookmark" class="crp_title">OOPost Types: Classes Part 1 &#8211; Object Oriented WordPress 3.0 App</a></li><li><a
href="http://new2wp.com/pro/wordpress-dashboard-themes/" rel="bookmark" class="crp_title">How To Create WordPress Dashboard Themes And Styles</a></li><li><a
href="http://new2wp.com/pro/wordpress-custom-post-types-object-oriented-series3/" rel="bookmark" class="crp_title">OOPost Types: Objects Part 3 &#8211; Object Oriented WordPress 3.0 App</a></li><li><a
href="http://new2wp.com/rookie/bug-wordpress3-taxonomies-wp_nav_menu/" rel="bookmark" class="crp_title">A Bug I Found With WordPress 3.0 Taxonomies And wp_nav_menu</a></li><li><a
href="http://new2wp.com/noob/wordpress-custom-templates-the-easy-and-most-logical-method/" rel="bookmark" class="crp_title">WordPress Custom Templates: The EASY and Most Logical Method</a></li></ul></div><p><a
href="%%postur%%" target="_blank">WordPress Theme: 3.0 Basics &#8211; A Higher Starting Point For Theme Developers</a></p><ul><li><a
href="http://twitter.com/home?status=WordPress Theme: 3.0 Basics &#8211; A Higher Starting Point For Theme Developers http://new2wp.com/pro/basic-theme-framework-wordpress3-custom-post-type/" rel="nofollow" title="Post this on Twitter" target="_blank">Post this on Twitter</a></li><li><a
href="http://facebook.com/share.php?u=http://new2wp.com/pro/basic-theme-framework-wordpress3-custom-post-type/&title=WordPress Theme: 3.0 Basics &#8211; A Higher Starting Point For Theme Developers" rel="nofollow" title="Post this on Facebook" target="_blank">Post this on Facebook</a></li><li><a
href="http://www.stumbleupon.com/submit?url=http://new2wp.com/pro/basic-theme-framework-wordpress3-custom-post-type/&title=WordPress Theme: 3.0 Basics &#8211; A Higher Starting Point For Theme Developers" rel="nofollow" title="Stumble This Post">Stumble This Post</a></li><li><a
href="http://del.icio.us/post?url=http://new2wp.com/pro/basic-theme-framework-wordpress3-custom-post-type/&title=WordPress Theme: 3.0 Basics &#8211; A Higher Starting Point For Theme Developers" rel="nofollow" title="Share this on del.icio.us" target="_blank">Share this on del.icio.us</a></li><li><a
href="http://digg.com/submit?phase=2&url=http://new2wp.com/pro/basic-theme-framework-wordpress3-custom-post-type/&title=WordPress Theme: 3.0 Basics &#8211; A Higher Starting Point For Theme Developers" rel="nofollow" title="Digg This Post" target="_blank">Digg This Post</a></li><li><a
href="http://thewebblend.com/submit?url=http://new2wp.com/pro/basic-theme-framework-wordpress3-custom-post-type/&title=WordPress Theme: 3.0 Basics &#8211; A Higher Starting Point For Theme Developers" rel="nofollow" title="Blend This!" target="_blank">Blend This!</a></li><li><a
href="http://designbump.com/submit?url=http://new2wp.com/pro/basic-theme-framework-wordpress3-custom-post-type/&title=WordPress Theme: 3.0 Basics &#8211; A Higher Starting Point For Theme Developers" rel="nofollow" title="DesignBump This" target="_blank">DesignBump This</a></li><li><a
href="http://www.designfloat.com/submit.php?url=http://new2wp.com/pro/basic-theme-framework-wordpress3-custom-post-type/&title=WordPress Theme: 3.0 Basics &#8211; A Higher Starting Point For Theme Developers" rel="nofollow" title="Post this on DesignFloat" target="_blank">Post this on DesignFloat</a></li></ul><p><a
href="http://new2wp.com"><img
src="http://tweeaks.com/wp-content/uploads/2010/08/new2wp-468x60px1.png" alt="New2WP" /></a></p><p><small>Copyright ©2010 <a
href="http://new2wp.com">New2WP.com</a>. Posted by jaredwilli on 2010 |<a
href="http://new2wp.com/pro/basic-theme-framework-wordpress3-custom-post-type/">Permalink</a></p>]]></content:encoded> <wfw:commentRss>http://new2wp.com/pro/basic-theme-framework-wordpress3-custom-post-type/feed/</wfw:commentRss> <slash:comments>11</slash:comments> </item> <item><title>[Poll] How Long Have You Been Making Websites</title><link>http://new2wp.com/news/how-long-making-websites/</link> <comments>http://new2wp.com/news/how-long-making-websites/#comments</comments> <pubDate>Sun, 01 Aug 2010 13:00:40 +0000</pubDate> <dc:creator>Jared</dc:creator> <category><![CDATA[Site News]]></category> <category><![CDATA[Poll]]></category><guid
isPermaLink="false">http://new2wp.com/?p=2426</guid> <description><![CDATA[We're interested to know how long you've been doing web design, and making websites. Come cast your vote in the poll, and add a comment telling us a little more if you like.]]></description> <content:encoded><![CDATA[<h2>Are You New or Just New2WP?</h2><p>I was curious to know how long some of those who follow this site have been into making websites. For some people making WordPress sites is just a hobby, and others such as myself, take it a lot more seriously, and have been at it for some time now.</p><p>Tell us how long you've been doing this. Whether you're visiting New2WP today to read your first ever tutorial and starting out or if you've been flipping functions like a freak for years now, we want to know.</p> <script type='text/javascript' language='javascript' charset='utf-8' src='http://s3.polldaddy.com/p/3555086.js'></script><noscript> <a
href='http://answers.polldaddy.com/poll/3555086/'>View Poll</a></noscript><p>Be honest too, I know how long each and everyone of you has been doing this, Eye have my I on you... Still reading this? Or did you stop paying attention when you got to the poll?</p><p>In case you were wondering what the poll results for the last poll, Are you using WP 3.0 yet? I some how lost the post, and can't be bothered to write it again. Not many people weren't using 3.0 though, I know that.</p><div
id="crp_related"><h3>Related Posts</h3><ul
class="relatedposts"><li><a
href="http://new2wp.com/news/march-poll-ebooks-or-real-books/" rel="bookmark" class="crp_title">March Poll: eBooks or Real Books?</a></li><li><a
href="http://new2wp.com/news/poll-results-are-you-using-wordpress-3-0-yet/" rel="bookmark" class="crp_title">Poll Results: Are You Using WordPress 3.0 Yet?</a></li><li><a
href="http://new2wp.com/news/using-wordpress30-yet/" rel="bookmark" class="crp_title">Poll: Have You Started Using WordPress 3.0 Yet?</a></li><li><a
href="http://new2wp.com/noob/why-shouldnt-use-wordpress-admin-account/" rel="bookmark" class="crp_title">Why You Shouldn&#8217;t Use The WordPress Admin Account</a></li><li><a
href="http://new2wp.com/featured/363-photoshop-color-swatches-download/" rel="bookmark" class="crp_title">363 Vibrant Color Swatches For Photoshop Download Pack</a></li></ul></div><p><a
href="%%postur%%" target="_blank">[Poll] How Long Have You Been Making Websites</a></p><ul><li><a
href="http://twitter.com/home?status=[Poll] How Long Have You Been Making Websites http://new2wp.com/news/how-long-making-websites/" rel="nofollow" title="Post this on Twitter" target="_blank">Post this on Twitter</a></li><li><a
href="http://facebook.com/share.php?u=http://new2wp.com/news/how-long-making-websites/&title=[Poll] How Long Have You Been Making Websites" rel="nofollow" title="Post this on Facebook" target="_blank">Post this on Facebook</a></li><li><a
href="http://www.stumbleupon.com/submit?url=http://new2wp.com/news/how-long-making-websites/&title=[Poll] How Long Have You Been Making Websites" rel="nofollow" title="Stumble This Post">Stumble This Post</a></li><li><a
href="http://del.icio.us/post?url=http://new2wp.com/news/how-long-making-websites/&title=[Poll] How Long Have You Been Making Websites" rel="nofollow" title="Share this on del.icio.us" target="_blank">Share this on del.icio.us</a></li><li><a
href="http://digg.com/submit?phase=2&url=http://new2wp.com/news/how-long-making-websites/&title=[Poll] How Long Have You Been Making Websites" rel="nofollow" title="Digg This Post" target="_blank">Digg This Post</a></li><li><a
href="http://thewebblend.com/submit?url=http://new2wp.com/news/how-long-making-websites/&title=[Poll] How Long Have You Been Making Websites" rel="nofollow" title="Blend This!" target="_blank">Blend This!</a></li><li><a
href="http://designbump.com/submit?url=http://new2wp.com/news/how-long-making-websites/&title=[Poll] How Long Have You Been Making Websites" rel="nofollow" title="DesignBump This" target="_blank">DesignBump This</a></li><li><a
href="http://www.designfloat.com/submit.php?url=http://new2wp.com/news/how-long-making-websites/&title=[Poll] How Long Have You Been Making Websites" rel="nofollow" title="Post this on DesignFloat" target="_blank">Post this on DesignFloat</a></li></ul><p><a
href="http://new2wp.com"><img
src="http://tweeaks.com/wp-content/uploads/2010/08/new2wp-468x60px1.png" alt="New2WP" /></a></p><p><small>Copyright ©2010 <a
href="http://new2wp.com">New2WP.com</a>. Posted by jaredwilli on 2010 |<a
href="http://new2wp.com/news/how-long-making-websites/">Permalink</a></p>]]></content:encoded> <wfw:commentRss>http://new2wp.com/news/how-long-making-websites/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Learn To Make Pain Free Short Codes With WordPress</title><link>http://new2wp.com/rookie/learn-to-make-pain-free-short-codes-with-wordpress/</link> <comments>http://new2wp.com/rookie/learn-to-make-pain-free-short-codes-with-wordpress/#comments</comments> <pubDate>Fri, 23 Jul 2010 09:00:54 +0000</pubDate> <dc:creator>Jared</dc:creator> <category><![CDATA[Rookie]]></category> <category><![CDATA[Guide]]></category> <category><![CDATA[Short Codes]]></category> <category><![CDATA[Wordcamp]]></category><guid
isPermaLink="false">http://new2wp.com/?p=2036</guid> <description><![CDATA[Have been curious about how to create your own short codes for streamlining your blog post writing? Shortcodes are very useful for doing things that you can't normally do most of the time, so check out this presentation on how to make short codes painlessly.]]></description> <content:encoded><![CDATA[<h2><a
href="http://www.slideshare.net/squaredesign/short-codes-pain-free-magic" title="Short Codes: Pain Free Magic">Short Codes: Pain Free Magic</a></h2><p>This was <a
href="http://twitter.com/mikesusz">Michael Susz's</a> presentation slides on creating short codes at <a
href="http://wordcampboston.com">Wordcamp Boston</a>. I found it to be a great help in understanding the code behind short codes, even though I missed the actual session since <a
href="http://tweeaks.com/blogging/my-experience-as-a-volunteer-at-wordcamp-boston/">I was a volunteer</a>, and very busy helping out that day.</p><p><object
id="__sse2977589" width="560" height="355"><param
name="movie" value="http://static.slidesharecdn.com/swf/ssplayer2.swf?doc=shortcodes-slides-100123101324-phpapp01&#038;stripped_title=short-codes-pain-free-magic" /><param
name="allowFullScreen" value="true"/><param
name="allowScriptAccess" value="always"/><embed
name="__sse2977589" src="http://static.slidesharecdn.com/swf/ssplayer2.swf?doc=shortcodes-slides-100123101324-phpapp01&#038;stripped_title=short-codes-pain-free-magic" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="560" height="355"></embed></object></p><p>I will try to do a follow up post and explain more in-depth how to create WordPress shortcodes, and how to do some of the various things that are possible with them when I have more time to.</p><p>Hope this has helped you understand them better like it did for me.</p><div
id="crp_related"><h3>Related Posts</h3><ul
class="relatedposts"><li><a
href="http://new2wp.com/noob/new2wp-launch-learn-even-more-about-wordpress/" rel="bookmark" class="crp_title">New2WP.com Launch: Learn Even More About WordPress</a></li><li><a
href="http://new2wp.com/news/wordpress-3-0-available-download/" rel="bookmark" class="crp_title">WordPress 3.0 Now Officially Available For Download</a></li><li><a
href="http://new2wp.com/noob/video-using-jquery-in-wordpress-presented-by-jim-doran/" rel="bookmark" class="crp_title">[Video] Using jQuery In WordPress Presented By Jim Doran</a></li><li><a
href="http://new2wp.com/rookie/interview-with-matt-mullenweg-about-wordpress-3-0-and-more/" rel="bookmark" class="crp_title">Interview With Matt Mullenweg About WordPress 3.0 And More</a></li><li><a
href="http://new2wp.com/noob/best-wordpress-hosting-service/" rel="bookmark" class="crp_title">Reliable WordPress Hosting You Never Knew You Wanted</a></li></ul></div><p><a
href="%%postur%%" target="_blank">Learn To Make Pain Free Short Codes With WordPress</a></p><ul><li><a
href="http://twitter.com/home?status=Learn To Make Pain Free Short Codes With WordPress http://new2wp.com/rookie/learn-to-make-pain-free-short-codes-with-wordpress/" rel="nofollow" title="Post this on Twitter" target="_blank">Post this on Twitter</a></li><li><a
href="http://facebook.com/share.php?u=http://new2wp.com/rookie/learn-to-make-pain-free-short-codes-with-wordpress/&title=Learn To Make Pain Free Short Codes With WordPress" rel="nofollow" title="Post this on Facebook" target="_blank">Post this on Facebook</a></li><li><a
href="http://www.stumbleupon.com/submit?url=http://new2wp.com/rookie/learn-to-make-pain-free-short-codes-with-wordpress/&title=Learn To Make Pain Free Short Codes With WordPress" rel="nofollow" title="Stumble This Post">Stumble This Post</a></li><li><a
href="http://del.icio.us/post?url=http://new2wp.com/rookie/learn-to-make-pain-free-short-codes-with-wordpress/&title=Learn To Make Pain Free Short Codes With WordPress" rel="nofollow" title="Share this on del.icio.us" target="_blank">Share this on del.icio.us</a></li><li><a
href="http://digg.com/submit?phase=2&url=http://new2wp.com/rookie/learn-to-make-pain-free-short-codes-with-wordpress/&title=Learn To Make Pain Free Short Codes With WordPress" rel="nofollow" title="Digg This Post" target="_blank">Digg This Post</a></li><li><a
href="http://thewebblend.com/submit?url=http://new2wp.com/rookie/learn-to-make-pain-free-short-codes-with-wordpress/&title=Learn To Make Pain Free Short Codes With WordPress" rel="nofollow" title="Blend This!" target="_blank">Blend This!</a></li><li><a
href="http://designbump.com/submit?url=http://new2wp.com/rookie/learn-to-make-pain-free-short-codes-with-wordpress/&title=Learn To Make Pain Free Short Codes With WordPress" rel="nofollow" title="DesignBump This" target="_blank">DesignBump This</a></li><li><a
href="http://www.designfloat.com/submit.php?url=http://new2wp.com/rookie/learn-to-make-pain-free-short-codes-with-wordpress/&title=Learn To Make Pain Free Short Codes With WordPress" rel="nofollow" title="Post this on DesignFloat" target="_blank">Post this on DesignFloat</a></li></ul><p><a
href="http://new2wp.com"><img
src="http://tweeaks.com/wp-content/uploads/2010/08/new2wp-468x60px1.png" alt="New2WP" /></a></p><p><small>Copyright ©2010 <a
href="http://new2wp.com">New2WP.com</a>. Posted by jaredwilli on 2010 |<a
href="http://new2wp.com/rookie/learn-to-make-pain-free-short-codes-with-wordpress/">Permalink</a></p>]]></content:encoded> <wfw:commentRss>http://new2wp.com/rookie/learn-to-make-pain-free-short-codes-with-wordpress/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>New2Tip: Allow Visitors To Search By Category</title><link>http://new2wp.com/noob/new2tip-allow-visitors-to-search-by-category/</link> <comments>http://new2wp.com/noob/new2tip-allow-visitors-to-search-by-category/#comments</comments> <pubDate>Thu, 22 Jul 2010 10:00:09 +0000</pubDate> <dc:creator>Jared</dc:creator> <category><![CDATA[Noob]]></category> <category><![CDATA[Categorys]]></category> <category><![CDATA[Forms]]></category> <category><![CDATA[Search]]></category><guid
isPermaLink="false">http://new2wp.com/?p=1729</guid> <description><![CDATA[Learn how to easily add a category drop down select box to your WordPress search form to provide a more customizable way to search for a specific post on your site.]]></description> <content:encoded><![CDATA[<h2>Changing The Form</h2><p>To add the drop down select menu for categories, you simply use the <span
id="fixed">wp_dropdown_categories()</span> function with at least one parameter of <span
id="fixed">show_option_none=Select category</span>. You can also <a
href="http://codex.WordPress.org/Function_Reference/wp_dropdown_categories">add other options</a> too if you like.</p><p>The following code is what I use for the searchform.php here on New2WP.</p><pre class="brush: php;">
&lt;!-- The searchform.php template code --&gt;
&lt;form id=&quot;searchform&quot; method=&quot;get&quot; action=&quot;&lt;?php bloginfo('url'); ?&gt;&quot;&gt;
    &lt;input type=&quot;text&quot; name=&quot;s&quot; id=&quot;s&quot; size=&quot;15&quot; /&gt;
    &lt;?php wp_dropdown_categories('show_option_none=Select category'); ?&gt;
		&lt;input name=&quot;s&quot; id=&quot;s&quot; type=&quot;text&quot; class=&quot;searchinput&quot; value=&quot;&lt;?php if ( is_search() ) echo esc_attr( get_search_query() ); else echo 'Search'; ?&gt;&quot; onfocus=&quot;if(this.value==this.defaultValue)this.value='';&quot; onblur=&quot;if(this.value=='')this.value=this.defaultValue;&quot; /&gt;
    &lt;input type=&quot;submit&quot; value=&quot;Search&quot; /&gt;
&lt;/form&gt;
</pre><h2>Add a function</h2><p>In order to hook into the search query that happens when you submit the search form you need to add this to your functions.php file.</p><pre class="brush: php;">
// Add to functions.php file.
add_action('pre_get_posts', 'search_by_cat');

function search_by_cat() {
	global $wp_query;

	if (is_search()) {
                $cat = intval( $_GET['cat'] );
                $cat = ( $cat &gt; 0  ) ? $cat : '';
                $wp_query-&gt;query_vars['cat'] = $cat;
    }
}
</pre><p>If you have any questions about this please post a comment below and let me know. This is something that is so easy though, that it took me just about 10 minutes to add to New2WP on all pages besides the homepage. It shouldn't be too difficult to figure out, but let me know if you need help I'm happy to help with anything.</p><div
id="crp_related"><h3>Related Posts</h3><ul
class="relatedposts"><li><a
href="http://new2wp.com/rookie/create-social-bookmark-buttons/" rel="bookmark" class="crp_title">Create Your Own Social Bookmark Button Links</a></li><li><a
href="http://new2wp.com/noob/highlighting-onclick-shortlink-wordpress3/" rel="bookmark" class="crp_title">New2Tip: Adding A Click Highlighting Shortlink Input To Posts</a></li><li><a
href="http://new2wp.com/rookie/understanding-conditional-statements/" rel="bookmark" class="crp_title">Understanding Conditional Statements</a></li><li><a
href="http://new2wp.com/noob/adding-backwards-compatible-wordpress-menus-to-your-theme/" rel="bookmark" class="crp_title">Adding Backwards Compatible WordPress Menus To Your Theme</a></li><li><a
href="http://new2wp.com/noob/how-to-remove-nofollow-from-your-comments/" rel="bookmark" class="crp_title">How To Remove nofollow From Your Comments</a></li></ul></div><p><a
href="%%postur%%" target="_blank">New2Tip: Allow Visitors To Search By Category</a></p><ul><li><a
href="http://twitter.com/home?status=New2Tip: Allow Visitors To Search By Category http://new2wp.com/noob/new2tip-allow-visitors-to-search-by-category/" rel="nofollow" title="Post this on Twitter" target="_blank">Post this on Twitter</a></li><li><a
href="http://facebook.com/share.php?u=http://new2wp.com/noob/new2tip-allow-visitors-to-search-by-category/&title=New2Tip: Allow Visitors To Search By Category" rel="nofollow" title="Post this on Facebook" target="_blank">Post this on Facebook</a></li><li><a
href="http://www.stumbleupon.com/submit?url=http://new2wp.com/noob/new2tip-allow-visitors-to-search-by-category/&title=New2Tip: Allow Visitors To Search By Category" rel="nofollow" title="Stumble This Post">Stumble This Post</a></li><li><a
href="http://del.icio.us/post?url=http://new2wp.com/noob/new2tip-allow-visitors-to-search-by-category/&title=New2Tip: Allow Visitors To Search By Category" rel="nofollow" title="Share this on del.icio.us" target="_blank">Share this on del.icio.us</a></li><li><a
href="http://digg.com/submit?phase=2&url=http://new2wp.com/noob/new2tip-allow-visitors-to-search-by-category/&title=New2Tip: Allow Visitors To Search By Category" rel="nofollow" title="Digg This Post" target="_blank">Digg This Post</a></li><li><a
href="http://thewebblend.com/submit?url=http://new2wp.com/noob/new2tip-allow-visitors-to-search-by-category/&title=New2Tip: Allow Visitors To Search By Category" rel="nofollow" title="Blend This!" target="_blank">Blend This!</a></li><li><a
href="http://designbump.com/submit?url=http://new2wp.com/noob/new2tip-allow-visitors-to-search-by-category/&title=New2Tip: Allow Visitors To Search By Category" rel="nofollow" title="DesignBump This" target="_blank">DesignBump This</a></li><li><a
href="http://www.designfloat.com/submit.php?url=http://new2wp.com/noob/new2tip-allow-visitors-to-search-by-category/&title=New2Tip: Allow Visitors To Search By Category" rel="nofollow" title="Post this on DesignFloat" target="_blank">Post this on DesignFloat</a></li></ul><p><a
href="http://new2wp.com"><img
src="http://tweeaks.com/wp-content/uploads/2010/08/new2wp-468x60px1.png" alt="New2WP" /></a></p><p><small>Copyright ©2010 <a
href="http://new2wp.com">New2WP.com</a>. Posted by jaredwilli on 2010 |<a
href="http://new2wp.com/noob/new2tip-allow-visitors-to-search-by-category/">Permalink</a></p>]]></content:encoded> <wfw:commentRss>http://new2wp.com/noob/new2tip-allow-visitors-to-search-by-category/feed/</wfw:commentRss> <slash:comments>1</slash:comments> </item> <item><title>OOPost Types: Methods Part 2 &#8211; Object Oriented WordPress 3.0 App</title><link>http://new2wp.com/pro/wordpress-custom-post-types-object-oriented-series2/</link> <comments>http://new2wp.com/pro/wordpress-custom-post-types-object-oriented-series2/#comments</comments> <pubDate>Wed, 21 Jul 2010 11:00:33 +0000</pubDate> <dc:creator>Jared</dc:creator> <category><![CDATA[Pro]]></category> <category><![CDATA[Methods]]></category> <category><![CDATA[OOP]]></category> <category><![CDATA[Post types]]></category> <category><![CDATA[Tutorials]]></category> <category><![CDATA[wp3.0]]></category><guid
isPermaLink="false">http://new2wp.com/?p=1934</guid> <description><![CDATA[This is the second part of building a WordPress 3.0 custom post type class. In this tutorial we'll build the methods that the class can use, and that any objects you build later on can access and use as well.]]></description> <content:encoded><![CDATA[<h2>Second Day Of Classes And OOPost Types</h2><p>In the first tutorial - <a
href="http://new2wp.com/pro/WordPress-custom-post-types-object-oriented-series1/">Classes part 1 of OOPost Types</a>, I showed you how to start building the class for a <a
href="http://new2wp.com/pro/WordPress-custom-post-types-and-taxonomies-done-right/">custom post type</a> to submit sites, essentially making a type of social bookmarking sort of post type. If you didn't read through that post and just skipped to this one I would recommend that you go back and <a
href="http://new2wp.com/pro/WordPress-custom-post-types-object-oriented-series1/">review it first</a>. Otherwise here is the code that I left off with in posttypes.php.</p><pre class="brush: php;">
&lt;?php
// Create a post type class for site posts
// To use as a bookmarking post type for sites you want to save/share.
class TypeSites {
    public $meta_fields = array( 'title', 'description', 'siteurl', 'category', 'post_tags' );

	public function TypeSites() {

        $siteArgs = array(
			'labels' =&gt; array(
                'name' =&gt; __( 'Sites', 'post type general name' ),
                'singular_name' =&gt; __( 'Site', 'post type singular name' ),
                'add_new' =&gt; __( 'Add New', 'site' ),
                'add_new_item' =&gt; __( 'Add New Site' ),
                'edit_item' =&gt; __( 'Edit Site' ),
                'new_item' =&gt; __( 'New Site' ),
                'view_item' =&gt; __( 'View Site' ),
                'search_items' =&gt; __( 'Search Sites' ),
                'not_found' =&gt;  __( 'No sites found in search' ),
                'not_found_in_trash' =&gt; __( 'No sites found in Trash' ),
			),
			'public' =&gt; true, 'show_ui' =&gt; true,
			'_builtin' =&gt; false,
			'capability_type' =&gt; 'post',
			'hierarchical' =&gt; false,
			'rewrite' =&gt; array('slug' =&gt; 'site'), // Permalinks. Fixes a 404 bug
			'query_var' =&gt; 'site',
			'taxonomies' =&gt;  array('category', 'post_tag'), // Add tags and categories taxonomies
			'supports' =&gt; array('title','editor','author','comments')
        );

        register_post_type( 'site', $siteArgs );	

	}

} // end of TypeSites{} class
?&gt;
</pre><p><a
href="http://www.servage.net/?coupon=cust12648"><img
src="http://images.servage.net/img/banners/smart/banner.php?type=fullbanner&amp;south=false" class="aligncenter" alt="Excellent Hosting- You Will Never Need Another Web Host Again" /></a></p><h2>Adding Methods To The Class Madness</h2><p>Starting where I left off, let's continue building our class by adding some methods, or functions as many people call them. First let's set up some custom columns for the Sites manage page. You've probably seen this code before but here it is again.</p><p><strong>UPDATED!</strong></p><pre class="brush: php;">
	// Create the columns and heading title text
	public function site_edit_columns($columns) {
        $columns = array(
			'cb' 		=&gt; '&lt;input type=&quot;checkbox&quot; /&gt;',
			'title' 		=&gt; 'Site Title',
			'url'	 	=&gt; 'URL',
			'category'	=&gt; 'Category',
			'post_tags' =&gt; 'Tags',
			'siteurl' 	=&gt; 'Screenshot',
        );
        return $columns;
    }
	// switching cases based on which $column we show the content of it
    public function site_custom_columns($column) {
		global $post;
        switch ($column) {
            case &quot;title&quot; : the_title();
                break;
            case &quot;url&quot; : $m = $this-&gt;mshot(150); echo '&lt;a href=&quot;'.$m[0].'&quot; target=&quot;_blank&quot;&gt;'.$m[0].'&lt;/a&gt;';
				break;
            case &quot;category&quot; : the_category();
				break;
            case &quot;post_tags&quot; : the_tags('',', ');
                break;
            case &quot;siteurl&quot; : $m = $this-&gt;mshot(150); echo $m[1];
				break;
        }
    }
</pre><p>The difference with this custom column code compared to other custom columns codes is that it is invoking a method to generate the content displayed in two of the columns. This is a method that I have added below as an update to this post.</p><p>It sets the variable $m to the method mshot() with a size of 150. The number is used to make the image size. It is required, but will not affect the output when just getting the Url. The mshot() function returns an array containing the values of the url and image output. In order to retrieve them, we echo $m[0] for Url, and $m[1] for the auto generated site screenshot. This might be difficult to follow, as it is hard to explain. It took me a while to figure out how to get it to work, hence the lateness in my update.</p><p>Now let's add two more functions. First is a function for hooking into the template redirect action in WordPress, which will be used for setting up use of <a
href="http://new2wp.com/noob/WordPress-custom-templates-the-easy-and-most-logical-method/">custom templates</a> for Sites, which I'll explain more when we create new objects of this class.</p><p><strong>UPDATE</strong>: $wp variable should be $wp_query or you get Notice: Undefined index 'post_type' in... I just realized this sorry.</p><pre class="brush: php;">
	// Template redirect for custom templates
    public function template_redirect() {
        global $wp_query;
        if ($wp_query-&gt;query_vars['post_type'] == 'site') {
            include(TEMPLATEPATH . '/single-site.php'); // a custom single-slug.php template
            die();
        } else {
			$wp_query-&gt;is_404 = true;
		}
    }
</pre><p><a
href="https://www.e-junkie.com/ecom/gb.php?cl=12635&#038;c=ib&#038;aff=81542" target="ejejcsingle"><img
src="http://new2wp.com/wp-content/uploads/2010/06/WProckstar_468x60.jpg" alt="questions" title="questions" class="aligncenter size-full wp-image-1691" /></a><br
/> This function is used for inserting new Site posts using the <span
id="fixed">wp_insert_post()</span> function <a
href="http://codex.WordPress.org/Function_Reference/wp_insert_post">now available in WordPress 3.0</a>. It will be extremely useful later on in the series, too.</p><pre class="brush: php;">
	// For inserting posts
    public function wp_insert_post($post_id, $post = null) {
        if ($post-&gt;post_type == &quot;site&quot;) {
            foreach ($this-&gt;meta_fields as $key) {
                $value = @$_POST[$key];
                if (empty($value)) {
                    delete_post_meta($post_id, $key);
                    continue;
                }
                if (!is_array($value)) {
                    if (!update_post_meta($post_id, $key, $value)) {
                        add_post_meta($post_id, $key, $value);
                    }
                } else {
                    delete_post_meta($post_id, $key);
                    foreach ($value as $entry) add_post_meta($post_id, $key, $entry);
                }
            }
        }
    }
</pre><p>Notice that the <span
id="fixed">wp_insert_post()</span> function uses the <span
id="fixed">$meta_fields</span> variable we've set up in the first tutorial. It is referred to using <span
id="fixed">$this->meta_fields</span> since it is being used inside the class method.</p><h2>Adding Custom Meta Boxes</h2><p>Using the <span
id="fixed">add_meta_box()</span> function you are able to hook into the posting page and add form fields. I plan to do a separate post for meta boxes as part of this post series so I am not going to go into much detail here.</p><p>Basically what is going on here is the <span
id="fixed">admin_init()</span> function initializes the <span
id="fixed">meta_options()</span> function. The <span
id="fixed">meta_options()</span> function gets the Url if one exists in the input field, and runs it through a wacky little script I created for allowing submitted Urls to work whether they include the <span
id="fixed">http://</span> part of the Url or not. So <strong>http://new2wp.com</strong> AND <strong>new2wp.com</strong> will both be accepted, and work with the following.</p><p>The Url is then used to create a new Url that is encoded and appended to <span
id="fixed">http://s.WordPress.com/mshots/v1/</span> to create a live screenshot of the page which the Url points to.<br
/> The input fields are then added. The first one is where you enter the Url, and the second one is just for making the new Url. The screenshot or properly known as, mshot, image it generates is then echoed out below the two input fields with the <span
id="fixed">'?w=250'</span> parameter appended to the end of it. This is to tell the mshot image it should have a width of 250 pixels. This code took me quite some time to compile and get working so enjoy it.</p><pre class="brush: php;">
	// Add meta box
	function admin_init() {
        add_meta_box(&quot;siteS-meta&quot;, &quot;Site&quot;, array(&amp;$this, &quot;meta_options&quot;), &quot;site&quot;, &quot;side&quot;, &quot;high&quot;);
    }

	// Admin post meta contents
	public function meta_options() {
		global $post, $url;
		$custom = get_post_custom($post-&gt;ID);
		$url = $custom[&quot;siteurl&quot;][0];
		$myurl = trailingslashit( get_post_meta( $post-&gt;ID, 'siteurl', true ) );
		if ( $myurl != '' ) {
			if ( preg_match( &quot;/http(s?):\/\//&quot;, $myurl )) {
				$siteurl = get_post_meta( $post-&gt;ID, 'siteurl', true );
				$mshoturl = 'http://s.WordPress.com/mshots/v1/' . urlencode( $myurl );
			} else {
				$siteurl = 'http://' . get_post_meta( $post-&gt;ID, 'siteurl', true );
				$mshoturl = 'http://s.WordPress.com/mshots/v1/' . urlencode( 'http://' . $myurl );
			}
			$imgsrc  = '&lt;img src=&quot;' . $mshoturl . '?w=250&quot; alt=&quot;' . $title . '&quot; title=&quot;' . $title . '&quot; /&gt;';
		} ?&gt;
		&lt;p&gt;&lt;label&gt;Clean Url: &lt;input id=&quot;siteurl&quot; size=&quot;26&quot; name=&quot;siteurl&quot; value=&quot;&lt;?php echo $url; ?&gt;&quot; /&gt;&lt;/label&gt;&lt;/p&gt;
		&lt;p&gt;&lt;label&gt;Mshot Url: &lt;input id=&quot;mshoturl&quot; size=&quot;26&quot; name=&quot;mshoturl&quot; value=&quot;&lt;?php echo $mshoturl; ?&gt;&quot; /&gt;&lt;/label&gt;&lt;/p&gt;
		&lt;p&gt;&lt;?php echo '&lt;a href=&quot;'.$siteurl.'&quot;&gt;'.$imgsrc.'&lt;/a&gt;'; ?&gt;&lt;/p&gt;
	&lt;?php
	} // end meta options
</pre><h2>UPDATE: This Is A Newly Added Method</h2><p>I apologize for not including this originally, my bad. Here is one more method to include after the meta_options function. This will output either the Url of a site post, or the image source including the size of the image by passing the object a number for the size. An example of for how to use this, refer to the custom columns code above. You will notice that the Url and image are output to create the separate columns for each site post. <span
id="fixed">$m = $this->mshot(150); echo $m[1];</span></p><pre class="brush: php;">
    public function mshot($mshotsize) {
        global $post, $url;
        $imgWidth = $mshotsize;
        $myurl = get_post_meta($post-&gt;ID, 'siteurl', true);
		if ( $myurl != '' ) {
			if ( preg_match( &quot;/http(s?):\/\//&quot;, $myurl )) {
				$siteurl = get_post_meta( $post-&gt;ID, 'siteurl', true );
				$mshoturl = 'http://s.WordPress.com/mshots/v1/' . urlencode( $myurl );
			} else {
				$siteurl = 'http://' . get_post_meta( $post-&gt;ID, 'siteurl', true );
				$mshoturl = 'http://s.WordPress.com/mshots/v1/' . urlencode('http://'.$myurl );
			}
		}
        $mshotimg = '&lt;img src=&quot;'.$mshoturl.'?w='.$imgWidth.'&quot; alt=&quot;'.get_the_title().'&quot; title=&quot;'.get_the_title().'&quot; /&gt;';

        return array( $siteurl, $mshotimg );
	}
</pre><p><a
href="http://page.ly/?a=79976200" title="Page.ly WordPress hosting for people like you and me"><img
border="0" src="http://page.ly/public/gfx/ab/pagely468x60_6.gif" alt="Page.ly WordPress hosting for people like you and me" class="aligncenter" /></a></p><h2>Initializing it for Takeoff</h2><p>We need to initialize the class functions, and add them to the dashboard admin, and then instantiate the class with a new object of it for hooking into the <span
id="fixed">'init'</span> action. To do that you can add the following to your <span
id="fixed">'register_post_type()</span> function just before the closing bracket.</p><p><strong>UPDATED!</strong> The correct hook for the <span
id="fixed">'site_edit_columns'</span> should be <span
id="fixed">manage_edit-site_columns()</span>.</p><pre class="brush: php;">
        add_action( 'admin_init', array(&amp;$this, 'admin_init') ); // this must be first
        add_action( 'template_redirect', array(&amp;$this, 'template_redirect') );
        add_action( 'wp_insert_post', array(&amp;$this, 'wp_insert_post'), 10, 2 );

		// add custom columns
		add_filter( 'manage_posts_custom_column', array( &amp;$this, 'site_custom_columns' ));
		add_action( 'manage_edit-site_columns', array ( &amp;$this, 'site_edit_columns' )); // manage_edit-{post_type}_columns used for custom post types
</pre><p>To make custom columns for custom post types, WordPress <span
id="fixed">manage_post_custom_columns()</span> also uses <span
id="fixed"><a
href="http://codex.WordPress.org/Plugin_API/Action_Reference/manage_posts_custom_column">manage_edit-{post_type}_columns</a></span> to edit the custom post type manage post page columns. Just using manage_post_custom_columns for custom post types will cause your 'post' manage page to be overwritten with your custom columns.</p><p>After that you need to create a new object of the class to instantiate the class. This function will be used to make a new instance of the class. The function is then added to the init hook for WordPress.</p><pre class="brush: php;">
/* Initialize Post Types */
add_action('init', 'pTypesInit');
function pTypesInit() {
    global $sites;
    $sites = new TypeSites();
}
</pre><p>The <span
id="fixed">pTypesInit()</span> function will be used to instantiate more post type classes later on in this series. By the time the series is over, the posttypes.php will be a work of art if ever one existed for custom post types.</p><h2>The Full Sites Custom Post Type Class</h2><p>This class is now complete. Of course you can always add or alter it however you like. Here is the full complete code.</p><pre class="brush: php;">
&lt;?php
// Initialize the Class and add the action
add_action('init', 'pTypesInit');
function pTypesInit() {
    global $sites;
    $sites = new TypeSites();
}

// Create a post type class for 'Site' posts
// To use as a bookmarking post type for sites you want to save/share.
class TypeSites {

	// Store the data
	public $meta_fields = array( 'title', 'description', 'siteurl', 'category', 'post_tags' );

	// The post type constructor
	public function TypeSites() {

        $siteArgs = array(
			'labels' =&gt; array(
                'name' =&gt; __( 'Sites', 'post type general name' ),
                'singular_name' =&gt; __( 'Site', 'post type singular name' ),
                'add_new' =&gt; __( 'Add New', 'site' ),
                'add_new_item' =&gt; __( 'Add New Site' ),
                'edit_item' =&gt; __( 'Edit Site' ),

                'new_item' =&gt; __( 'New Site' ),
                'view_item' =&gt; __( 'View Site' ),
                'search_items' =&gt; __( 'Search Sites' ),
                'not_found' =&gt;  __( 'No sites found in search' ),
                'not_found_in_trash' =&gt; __( 'No sites found in Trash' ),
			),
			'public' =&gt; true, 'show_ui' =&gt; true,
			'_builtin' =&gt; false,
			'capability_type' =&gt; 'post',
			'hierarchical' =&gt; false,
			'rewrite' =&gt; array('slug' =&gt; 'site'), // Permalinks. Fixes a 404 bug
			'query_var' =&gt; 'site',
			'taxonomies' =&gt;  array('category', 'post_tag'), // Add tags and categories taxonomies
			'supports' =&gt; array('title','editor','author','comments')
        );
        register_post_type( 'site', $siteArgs );	

	// Initialize the methods
        add_action( 'admin_init', array(&amp;$this, 'admin_init') );
        add_action( 'template_redirect', array(&amp;$this, 'template_redirect') );
        add_action( 'wp_insert_post', array(&amp;$this, 'wp_insert_post'), 10, 2 );

		// add custom columns
		add_filter( 'manage_posts_custom_column', array( &amp;$this, 'site_custom_columns' ));
		add_action( 'manage_edit-site_columns', array ( &amp;$this, 'site_edit_columns' )); // manage_edit-{post_type}_columns used for custom post types

	}

	// Create the columns and heading title text
	public function site_edit_columns($columns) {
        $columns = array(
			'cb' 		=&gt; '&lt;input type=&quot;checkbox&quot; /&gt;',
			'title' 		=&gt; 'Site Title',
			'url'	 	=&gt; 'URL',
			'category'	=&gt; 'Category',
			'post_tags' =&gt; 'Tags',
			'siteurl' 	=&gt; 'Screenshot',
        );
        return $columns;
    }
	// switching cases based on which $column we show the content of it
    public function site_custom_columns($column) {
		global $post;
        switch ($column) {
            case &quot;title&quot; : the_title();
                break;
            case &quot;url&quot; : $m = $this-&gt;mshot(100); echo '&lt;a href=&quot;'.$m[0].'&quot; target=&quot;_blank&quot;&gt;'.$m[0].'&lt;/a&gt;';
				break;
            case &quot;category&quot; : the_category();
				break;
            case &quot;post_tags&quot; : the_tags('',', ');
                break;
            case &quot;siteurl&quot; : $m = $this-&gt;mshot(150); echo $m[1];
				break;
        }
    }

	// Template redirect for custom templates
    public function template_redirect() {
        global $wp_query;
        if ( $wp_query-&gt;query_vars[&quot;post_type&quot;] == &quot;site&quot; ) {
            include( TEMPLATEPATH . &quot;/single-site.php&quot; ); // a custom single-slug.php template
            die();
        } else {
			$wp_query-&gt;is_404 = true;
		}
    }

	// For inserting new 'site' post type posts
    public function wp_insert_post($post_id, $post = null) {
        if ($post-&gt;post_type == &quot;site&quot;) {
            foreach ($this-&gt;meta_fields as $key) {
                $value = @$_POST[$key];
                if (empty($value)) {
                    delete_post_meta($post_id, $key);
                    continue;
                }
                if (!is_array($value)) {
                    if (!update_post_meta($post_id, $key, $value)) {
                        add_post_meta($post_id, $key, $value);
                    }
                } else {
                    delete_post_meta($post_id, $key);
                    foreach ($value as $entry) add_post_meta($post_id, $key, $entry);
                }
            }
        }
    }

	// Add meta box
	function admin_init() {
        add_meta_box( &quot;sites-meta&quot;, &quot;Site&quot;, array( &amp;$this, &quot;meta_options&quot; ), &quot;site&quot;, &quot;side&quot;, &quot;low&quot; );
    }

	// Admin post meta contents
	public function meta_options() {
		global $post, $url;
		$custom = get_post_custom($post-&gt;ID);
		$url = $custom[&quot;siteurl&quot;][0];
		$myurl = trailingslashit( get_post_meta( $post-&gt;ID, 'siteurl', true ) );
		if ( $myurl != '' ) {
			// Check if url has http:// or not so works either way
			if ( preg_match( &quot;/http(s?):\/\//&quot;, $myurl )) {
				$siteurl = get_post_meta( $post-&gt;ID, 'siteurl', true );
				$mshoturl = 'http://s.WordPress.com/mshots/v1/' . urlencode( $myurl );
			} else {
				$siteurl = 'http://' . get_post_meta( $post-&gt;ID, 'siteurl', true );
				$mshoturl = 'http://s.WordPress.com/mshots/v1/' . urlencode( 'http://' . $myurl );
			}
			$imgsrc  = '&lt;img src=&quot;' . $mshoturl . '?w=250&quot; alt=&quot;' . $title . '&quot; title=&quot;' . $title . '&quot; /&gt;';
		} ?&gt;

		&lt;p&gt;&lt;label&gt;Clean Url: &lt;input id=&quot;siteurl&quot; size=&quot;26&quot; name=&quot;siteurl&quot; value=&quot;&lt;?php echo $url; ?&gt;&quot; /&gt;&lt;/label&gt;&lt;/p&gt;
		&lt;p&gt;&lt;?php echo '&lt;a href=&quot;' . $siteurl . '&quot;&gt;' . $imgsrc . '&lt;/a&gt;'; ?&gt;&lt;/p&gt;

	&lt;?php
	} // end meta options

	// Generate output for the url or image source for each site post
    public function mshot($mshotsize) {
        global $post, $url;
        $imgWidth = $mshotsize;
        $myurl = get_post_meta($post-&gt;ID, 'siteurl', true);
		if ( $myurl != '' ) {
			if ( preg_match( &quot;/http(s?):\/\//&quot;, $myurl )) {
				$siteurl = get_post_meta( $post-&gt;ID, 'siteurl', true );
				$mshoturl = 'http://s.WordPress.com/mshots/v1/' . urlencode( $myurl );
			} else {
				$siteurl = 'http://' . get_post_meta( $post-&gt;ID, 'siteurl', true );
				$mshoturl = 'http://s.WordPress.com/mshots/v1/' . urlencode('http://'.$myurl );
			}
		}
        $mshotimg = '&lt;img src=&quot;'.$mshoturl.'?w='.$imgWidth.'&quot; alt=&quot;'.get_the_title().'&quot; title=&quot;'.get_the_title().'&quot; /&gt;';

        return array( $siteurl, $mshotimg );
	}

} // end of TypeSites{} class
?&gt;
</pre><p>This concludes the building of your first fully functional and intuitive Php Class for constructing a <a
href="http://codex.WordPress.org/Custom_Post_Types">WordPress 3.0 custom post type</a>. Save the posttypes.php file, and make sure to include it into your functions.php file. Then go to your dashboard to check out the new post type that should be added and working as a new section of the site. Please let me know of any mistakes I may have made or bugs that might be found. Cutting this code up and disecting it makes it easy for this to happen.</p><p><a
href="#add"><img
src="http://new2wp.com/wp-content/uploads/2010/06/questions.png" class="aligncenter" alt="Ask a question below" /></a><br
/> We will be using much of this same code with some minor changes, and replacing certain functions with others according to the different post type classes. But first let's try out this new class by adding some objects to a couple custom WordPress templates.</p><p>The next tutorial shows how to instantiate the class, and build a custom post type WordPress loop to query the custom post types posts that have been submitted.</p><div
class="postprev"><a
href="/pro/WordPress-custom-post-types-object-oriented-series1">&laquo; Part 1</a></div><div
class="postnext"><a
href="/pro/WordPress-custom-post-types-object-oriented-series3">Soon, Part 3 &raquo;</a></div><div
id="crp_related"><h3>Related Posts</h3><ul
class="relatedposts"><li><a
href="http://new2wp.com/pro/wordpress-custom-post-types-object-oriented-series3/" rel="bookmark" class="crp_title">OOPost Types: Objects Part 3 &#8211; Object Oriented WordPress 3.0 App</a></li><li><a
href="http://new2wp.com/noob/new2tip-allow-visitors-to-search-by-category/" rel="bookmark" class="crp_title">New2Tip: Allow Visitors To Search By Category</a></li><li><a
href="http://new2wp.com/pro/wordpress-custom-post-types-object-oriented-series1/" rel="bookmark" class="crp_title">OOPost Types: Classes Part 1 &#8211; Object Oriented WordPress 3.0 App</a></li><li><a
href="http://new2wp.com/noob/how-to-remove-nofollow-from-your-comments/" rel="bookmark" class="crp_title">How To Remove nofollow From Your Comments</a></li><li><a
href="http://new2wp.com/noob/adding-backwards-compatible-wordpress-menus-to-your-theme/" rel="bookmark" class="crp_title">Adding Backwards Compatible WordPress Menus To Your Theme</a></li></ul></div><p><a
href="%%postur%%" target="_blank">OOPost Types: Methods Part 2 &#8211; Object Oriented WordPress 3.0 App</a></p><ul><li><a
href="http://twitter.com/home?status=OOPost Types: Methods Part 2 &#8211; Object Oriented WordPress 3.0 App http://new2wp.com/pro/wordpress-custom-post-types-object-oriented-series2/" rel="nofollow" title="Post this on Twitter" target="_blank">Post this on Twitter</a></li><li><a
href="http://facebook.com/share.php?u=http://new2wp.com/pro/wordpress-custom-post-types-object-oriented-series2/&title=OOPost Types: Methods Part 2 &#8211; Object Oriented WordPress 3.0 App" rel="nofollow" title="Post this on Facebook" target="_blank">Post this on Facebook</a></li><li><a
href="http://www.stumbleupon.com/submit?url=http://new2wp.com/pro/wordpress-custom-post-types-object-oriented-series2/&title=OOPost Types: Methods Part 2 &#8211; Object Oriented WordPress 3.0 App" rel="nofollow" title="Stumble This Post">Stumble This Post</a></li><li><a
href="http://del.icio.us/post?url=http://new2wp.com/pro/wordpress-custom-post-types-object-oriented-series2/&title=OOPost Types: Methods Part 2 &#8211; Object Oriented WordPress 3.0 App" rel="nofollow" title="Share this on del.icio.us" target="_blank">Share this on del.icio.us</a></li><li><a
href="http://digg.com/submit?phase=2&url=http://new2wp.com/pro/wordpress-custom-post-types-object-oriented-series2/&title=OOPost Types: Methods Part 2 &#8211; Object Oriented WordPress 3.0 App" rel="nofollow" title="Digg This Post" target="_blank">Digg This Post</a></li><li><a
href="http://thewebblend.com/submit?url=http://new2wp.com/pro/wordpress-custom-post-types-object-oriented-series2/&title=OOPost Types: Methods Part 2 &#8211; Object Oriented WordPress 3.0 App" rel="nofollow" title="Blend This!" target="_blank">Blend This!</a></li><li><a
href="http://designbump.com/submit?url=http://new2wp.com/pro/wordpress-custom-post-types-object-oriented-series2/&title=OOPost Types: Methods Part 2 &#8211; Object Oriented WordPress 3.0 App" rel="nofollow" title="DesignBump This" target="_blank">DesignBump This</a></li><li><a
href="http://www.designfloat.com/submit.php?url=http://new2wp.com/pro/wordpress-custom-post-types-object-oriented-series2/&title=OOPost Types: Methods Part 2 &#8211; Object Oriented WordPress 3.0 App" rel="nofollow" title="Post this on DesignFloat" target="_blank">Post this on DesignFloat</a></li></ul><p><a
href="http://new2wp.com"><img
src="http://tweeaks.com/wp-content/uploads/2010/08/new2wp-468x60px1.png" alt="New2WP" /></a></p><p><small>Copyright ©2010 <a
href="http://new2wp.com">New2WP.com</a>. Posted by jaredwilli on 2010 |<a
href="http://new2wp.com/pro/wordpress-custom-post-types-object-oriented-series2/">Permalink</a></p>]]></content:encoded> <wfw:commentRss>http://new2wp.com/pro/wordpress-custom-post-types-object-oriented-series2/feed/</wfw:commentRss> <slash:comments>8</slash:comments> </item> <item><title>New2Tip: Adding A Click Highlighting Shortlink Input To Posts</title><link>http://new2wp.com/noob/highlighting-onclick-shortlink-wordpress3/</link> <comments>http://new2wp.com/noob/highlighting-onclick-shortlink-wordpress3/#comments</comments> <pubDate>Tue, 20 Jul 2010 14:00:37 +0000</pubDate> <dc:creator>Jared</dc:creator> <category><![CDATA[Noob]]></category> <category><![CDATA[Shortlinks]]></category> <category><![CDATA[Snippets]]></category> <category><![CDATA[wp3.0]]></category><guid
isPermaLink="false">http://new2wp.com/?p=1976</guid> <description><![CDATA[Learn how to utilize the new WordPress 3.0 shortlinks feature by adding an auto highlighting text input field to your posts that will highlight the current posts shortlink. This makes it easier to Cntrl + C to copy and paste somewhere else for sharing.And it's just kind of cool too.]]></description> <content:encoded><![CDATA[<h2>Using WordPress 3.0 Shortlinks</h2><p>This is a quick tip for how you can add an input form field to your posts that has the posts shortlink now built into WordPress 3.0, that automatically highlights for easy copying, just like the one you see at the bottom right of every post on New2WP.</p><p><strong>Here's an example of this</strong></p><p><span
class="shortlink">Shortlink:<br
/> <input
type="text" value="Click here to auto copy" onclick="this.focus(); this.select();" style="width:160px;" /></span></p><p>First check if the function exists incase for some reason it doesn't your theme won't break then.</p><pre class="brush: php;">
&lt;?php if ( function_exists( 'wp_get_shortlink' ) ) { ?&gt;
</pre><p>Then create a span element which will include the input field and if you want, the word Shortlink so that people know what it is for.</p><p>For the input value echo out the <span
id="fixed">wp_get_shortlink( get_the_ID() )</span> functions for getting the shortlink of the current post by it's ID.</p><p>Then add an onclick event with some Javascript code that says basically, when this is clicked, the input is in focus, this should be selected.</p><pre class="brush: php;">
	&lt;span class=&quot;shortlink&quot;&gt;Shortlink:
		&lt;input type='text' value='&lt;?php echo wp_get_shortlink(get_the_ID()); ?&gt;' onclick='this.focus(); this.select();' /&gt;
	&lt;/span&gt;
</pre><p>Finally, close the if statement first opened to check if the function exists.</p><pre class="brush: php;">
&lt;?php } ?&gt;
</pre><p>It's really as simple as that. You can style it with CSS if you want easily, and whatever else you can think of.</p><h3>Here's The Full Code</h3><pre class="brush: php;">
&lt;?php if ( function_exists( 'wp_get_shortlink' ) ) { ?&gt;
	&lt;span class=&quot;shortlink&quot;&gt;Shortlink:
		&lt;input type='text' value='&lt;?php echo wp_get_shortlink(get_the_ID()); ?&gt;' onclick='this.focus(); this.select();'  /&gt;
	&lt;/span&gt;
&lt;?php } ?&gt;
</pre><p>If you have questions, don't hesitate to post a comment below as always.</p><div
id="crp_related"><h3>Related Posts</h3><ul
class="relatedposts"><li><a
href="http://new2wp.com/noob/new2tip-allow-visitors-to-search-by-category/" rel="bookmark" class="crp_title">New2Tip: Allow Visitors To Search By Category</a></li><li><a
href="http://new2wp.com/noob/adding-backwards-compatible-wordpress-menus-to-your-theme/" rel="bookmark" class="crp_title">Adding Backwards Compatible WordPress Menus To Your Theme</a></li><li><a
href="http://new2wp.com/rookie/codes-snippets-for-wordpress-3-0-new-features/" rel="bookmark" class="crp_title">15 Snippets To Prepare Your Theme For WordPress 3.0</a></li><li><a
href="http://new2wp.com/noob/rss-subscribe-boxafter-wordpress-posts/" rel="bookmark" class="crp_title">Easily Add A Subscribe To Feed Reminder To The Bottom Of Your Posts</a></li><li><a
href="http://new2wp.com/rookie/change-the-color-wordpress-dashboard-and-replace-logo-with-yours/" rel="bookmark" class="crp_title">How To Change The Color Of The WordPress Dashboard And Replace Logo With Yours</a></li></ul></div><p><a
href="%%postur%%" target="_blank">New2Tip: Adding A Click Highlighting Shortlink Input To Posts</a></p><ul><li><a
href="http://twitter.com/home?status=New2Tip: Adding A Click Highlighting Shortlink Input To Posts http://new2wp.com/noob/highlighting-onclick-shortlink-wordpress3/" rel="nofollow" title="Post this on Twitter" target="_blank">Post this on Twitter</a></li><li><a
href="http://facebook.com/share.php?u=http://new2wp.com/noob/highlighting-onclick-shortlink-wordpress3/&title=New2Tip: Adding A Click Highlighting Shortlink Input To Posts" rel="nofollow" title="Post this on Facebook" target="_blank">Post this on Facebook</a></li><li><a
href="http://www.stumbleupon.com/submit?url=http://new2wp.com/noob/highlighting-onclick-shortlink-wordpress3/&title=New2Tip: Adding A Click Highlighting Shortlink Input To Posts" rel="nofollow" title="Stumble This Post">Stumble This Post</a></li><li><a
href="http://del.icio.us/post?url=http://new2wp.com/noob/highlighting-onclick-shortlink-wordpress3/&title=New2Tip: Adding A Click Highlighting Shortlink Input To Posts" rel="nofollow" title="Share this on del.icio.us" target="_blank">Share this on del.icio.us</a></li><li><a
href="http://digg.com/submit?phase=2&url=http://new2wp.com/noob/highlighting-onclick-shortlink-wordpress3/&title=New2Tip: Adding A Click Highlighting Shortlink Input To Posts" rel="nofollow" title="Digg This Post" target="_blank">Digg This Post</a></li><li><a
href="http://thewebblend.com/submit?url=http://new2wp.com/noob/highlighting-onclick-shortlink-wordpress3/&title=New2Tip: Adding A Click Highlighting Shortlink Input To Posts" rel="nofollow" title="Blend This!" target="_blank">Blend This!</a></li><li><a
href="http://designbump.com/submit?url=http://new2wp.com/noob/highlighting-onclick-shortlink-wordpress3/&title=New2Tip: Adding A Click Highlighting Shortlink Input To Posts" rel="nofollow" title="DesignBump This" target="_blank">DesignBump This</a></li><li><a
href="http://www.designfloat.com/submit.php?url=http://new2wp.com/noob/highlighting-onclick-shortlink-wordpress3/&title=New2Tip: Adding A Click Highlighting Shortlink Input To Posts" rel="nofollow" title="Post this on DesignFloat" target="_blank">Post this on DesignFloat</a></li></ul><p><a
href="http://new2wp.com"><img
src="http://tweeaks.com/wp-content/uploads/2010/08/new2wp-468x60px1.png" alt="New2WP" /></a></p><p><small>Copyright ©2010 <a
href="http://new2wp.com">New2WP.com</a>. Posted by jaredwilli on 2010 |<a
href="http://new2wp.com/noob/highlighting-onclick-shortlink-wordpress3/">Permalink</a></p>]]></content:encoded> <wfw:commentRss>http://new2wp.com/noob/highlighting-onclick-shortlink-wordpress3/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>OOPost Types: Classes Part 1 &#8211; Object Oriented WordPress 3.0 App</title><link>http://new2wp.com/pro/wordpress-custom-post-types-object-oriented-series1/</link> <comments>http://new2wp.com/pro/wordpress-custom-post-types-object-oriented-series1/#comments</comments> <pubDate>Mon, 19 Jul 2010 11:00:09 +0000</pubDate> <dc:creator>Jared</dc:creator> <category><![CDATA[Featured]]></category> <category><![CDATA[Pro]]></category> <category><![CDATA[Classes]]></category> <category><![CDATA[OOP]]></category> <category><![CDATA[Post types]]></category> <category><![CDATA[Tutorials]]></category> <category><![CDATA[wp3.0]]></category><guid
isPermaLink="false">http://new2wp.com/?p=1911</guid> <description><![CDATA[You like custom post types, and maybe you love/hate OOPhp. Now learn how to put them together to build a complex custom section of your WP site.This isn't the first article on WordPress custom post types and won't be the last. But I assure you that unlike all others, this one has classes. Too cheesey lol? Oh well, let's do this!!]]></description> <content:encoded><![CDATA[<h2>An OOP Post Series On WordPress 3.0 Custom Post Types</h2><p>I noticed how extremely in demand posts about custom post types are when I realized my <a
href="http://new2wp.com/pro/WordPress-custom-post-types-and-taxonomies-done-right/">previous post</a> is apparently the most popular page of this site almost doubling the homepage in page views.</p><p><a
href="http://codecanyon.net?ref=jaredwilli" target="_blank"><img
src="http://envato.s3.amazonaws.com/referrer_adverts/cc_300x250_v2.gif" alt="Code Canyon - 1000s of Code Snippets and Scripts" border="0" class="alignright" /></a>So if it's post types you people want to know about or just what <a
href="http://new2wp.com/tag/wp3-0/">WordPress 3.0</a> is now <em>really</em> capable of, then I will share with how to create classes for your post types, custom taxonomies, other various yet useful methods you can create for your classes, and then show you how to create objects which you can use in your WordPress theme to create a completely custom section of your site. I'll be incorporating some jQuery and Ajax even if all of that wasn't already enough.</p><p>I'll share with you some of the code that I've been writing and re-writing you don't even want to know how many times over again, in an effort to create what I want to call a super class for post types, but more on that later.</p><h3>What you will learn</h3><ul><li><strong>How to create classes for custom post types</strong></li><li><strong>Creating methods within your post type classes</strong></li><li><strong>Using new objects of your classes in theme templates</strong></li><li><strong>Plus much more to come...</strong></li></ul><p>I have been developing a complete application as a theme using multiple post types and taxonomies, classes and objects, and jQuery custom post forms which submit using the built in Ajax functions used to submit new posts in the dashboard, plus tons of other cool custom made capabilities.</p><p>It's a rather BIG project of mine that I started when 3.0 was still on the first beta version. Not sure how long ago that was, but I've been coding/designing this theme/app for MONTHS now, and it grows more complex and abstract every time I work on it. But enough about that, I could go on for days.</p><p><a
href="https://www.e-junkie.com/ecom/gb.php?cl=12635&amp;c=ib&amp;aff=81542" target="ejejcsingle"><img
src="http://new2wp.com/wp-content/uploads/2010/06/WProckstar_468x60.jpg" alt="Be A WordPress Rockstar" title="Be A WordPress Rockstar" class="aligncenter size-full wp-image-1691"></a></p><h2>The OOPost Types Class Is Now In Session!!!</h2><p>Since I don't really have a set number of posts planned for this series I'm not sure how to break it up. So I'll just start by showing how to build a class for a new custom post type.</p><p>You'll need to create a new file that will contain the code for the post type class and just name posttypes.php. In your theme directory create a new folder called /functions and save the posttypes.php file in there. This becomes useful in organizing your Php files and any custom code.</p><h2>1. Prepare your functions file</h2><p>Open your <strong>functions.php</strong> template for your theme and add the following code to the top before everything else.</p><pre class="brush: php;">
// Create a variable to the path to functions directory
$functionsdir = TEMPLATEPATH . '/functions';

// Include your posttypes.php file
require_once ( $functionsdir . '/posttypes.php' );
</pre><p>The functions directory variable will be useful, and while were here you might as well include your posttypes.php file so WordPress knows to do something with it.</p><h2>2. Declaring A Post Type Class</h2><p>Now you can start creating the class in posttypes.php. In Php you declare a class with the word <span
id="fixed">class</span> followed by the name of the class followed by curly brackets { }. It's similar to the way you create functions in php only you can't use parenthesis like functions do for passing variables. It's common for class names to start with a Capital letter unlike functions too.</p><pre class="brush: php;">
&lt;?php
// Create a post type class for site posts
// To use as a bookmarking post type for sites you want to save/share.
class TypeSites {

	// Do stuff...

} // end of TypeSites{} class
?&gt;
</pre><p>Within the brackets you can create methods which are really just functions, but are called methods. I may use both to refer to them just so you know what I mean. They are the same thing.</p><p>So now let's drop the code in here that you may have seen many times before for creating custom post types. Here's how I have set up the labels and other vars for a post type called Sites using the <span
id="fixed">$labels</span> like <a
href="http://new2wp.com/pro/WordPress-custom-post-types-and-taxonomies-done-right/">you are supposed to now</a>.</p><pre class="brush: php;">
&lt;?php
// Create a post type class for site posts
// To use as a bookmarking post type for sites you want to save/share.
class TypeSites {

	public function TypeSites() {

        $siteArgs = array(
			'labels' =&gt; array(
                'name' =&gt; __( 'Sites', 'post type general name' ),
                'singular_name' =&gt; __( 'Site', 'post type singular name' ),
                'add_new' =&gt; __( 'Add New', 'site' ),
                'add_new_item' =&gt; __( 'Add New Site' ),
                'edit_item' =&gt; __( 'Edit Site' ),
                'new_item' =&gt; __( 'New Site' ),
                'view_item' =&gt; __( 'View Site' ),
                'search_items' =&gt; __( 'Search Sites' ),
                'not_found' =&gt;  __( 'No sites found in search' ),
                'not_found_in_trash' =&gt; __( 'No sites found in Trash' ),
			),
			'public' =&gt; true, 'show_ui' =&gt; true,
			'_builtin' =&gt; false,
			'capability_type' =&gt; 'post',
			'hierarchical' =&gt; false,
			'rewrite' =&gt; array('slug' =&gt; 'site'),
			'query_var' =&gt; 'site',
			'supports' =&gt; array('title','editor','author','comments')
        );

        register_post_type( 'site', $siteArgs );	

	}

} // end of TypeSites{} class
?&gt;
</pre><p>I won't explain what all of these are for since there's 2000 articles on the web about it, but you can see that I set the rewrite to use <span
id="fixed">'site'</span> for the slug, and the query variable is set to <span
id="fixed">'site'</span>, and finally what the post type supports is <span
id="fixed">'title', 'editor', 'author', and 'comments'</span>.</p><p>We can use the title and TinyMCE editor that posts use instead of having to create meta boxes for, and we want to allow for showing the author of a site post as well as let people post comments to the posts. In another custom post type later in the series I'll show you how to utilize the TinyMCE editor as a custom meta box, not the way the default one is used.</p><p>The only thing that we need now is an input field for the site url. For that we create a <a
href="http://codex.WordPress.org/Function_Reference/add_meta_box">custom meta box</a> which we'll create in part 2 of Classes.</p><p>Instead of adding a <a
href="http://new2wp.com/pro/WordPress-custom-post-types-and-taxonomies-done-right/">custom taxonomy</a> for this post type so that we can organize the sites submitted properly, let's just use the built-in Tags and Categories in WordPress. This seems to be the best way to organize different sites I've found, unless you know a better way then please share.</p><p>The way you incorporate the tags and categories taxonomies is by adding the following to the <span
id="fixed">$siteargs</span> array we've created.</p><pre class="brush: php;">
'taxonomies' =&gt;  array('category', 'post_tag'),
</pre><p>So now our class should look like this.</p><pre class="brush: php;">
&lt;?php
// Create a post type class for site posts
// To use as a bookmarking post type for sites you want to save/share.
class TypeSites {

	public function TypeSites() {

        $siteArgs = array(
			'labels' =&gt; array(
                'name' =&gt; __( 'Sites', 'post type general name' ),
                'singular_name' =&gt; __( 'Site', 'post type singular name' ),
                'add_new' =&gt; __( 'Add New', 'site' ),
                'add_new_item' =&gt; __( 'Add New Site' ),
                'edit_item' =&gt; __( 'Edit Site' ),
                'new_item' =&gt; __( 'New Site' ),
                'view_item' =&gt; __( 'View Site' ),
                'search_items' =&gt; __( 'Search Sites' ),
                'not_found' =&gt;  __( 'No sites found in search' ),
                'not_found_in_trash' =&gt; __( 'No sites found in Trash' ),
			),
			'public' =&gt; true, 'show_ui' =&gt; true,
			'_builtin' =&gt; false,
			'capability_type' =&gt; 'post',
			'hierarchical' =&gt; false,
			'rewrite' =&gt; array('slug' =&gt; 'site'), // Permalinks. Fixes a 404 bug
			'query_var' =&gt; 'site',
			'taxonomies' =&gt;  array('category', 'post_tag'), // Add tags and categories taxonomies
			'supports' =&gt; array('title','editor','author','comments')
        );

        register_post_type( 'site', $siteArgs );	

	}

} // end of TypeSites{} class
?&gt;
</pre><h3>What's this public stuff?</h3><p>We will be creating some <span
id="fixed">public</span> variables and functions in this class. What that means basically is they are accessible from anywhere in your script. It is the easiest to use <a
href="http://www.tuxradar.com/practicalphp/6/7/0">access control modifier</a> because of this.</p><h3>Quick Overview of Access Control Modifiers</h3><ul><strong>Used for Variables or Functions...</strong></p><li><span
id="fixed">Public</span> - Can be used from anywhere in the script.</li><li><span
id="fixed">Private</span> - Can only be used by the object it is part of, it cannot be accessed elsewhere.</li><li><span
id="fixed">Protected</span> - Can only be used by the object it is part of, or descendants of that class.</li><li><span
id="fixed">Final</span> - Cannot be overridden in inherited classes.</li></ul><ul><strong>Used for Functions or Classes...</strong></p><li><span
id="fixed">Abstract</span> - Cannot be used directly. Must inherited from the functions or class first.</li></ul><p>We need to create a <a
href="http://www.tuxradar.com/practicalphp/6/7/1">public variable</a> that is used to store an array of the post data <span
id="fixed">'title', 'content', 'siteurl', 'category', and 'post_tags'</span>. Add the variable to the top of the class just after the first curly bracket like this.</p><pre class="brush: php;">
class TypeSites {
    public $meta_fields = array( 'title', 'description', 'siteurl', 'category', 'post_tags' );
</pre><p><strong>The class should now look like this.</strong></p><pre class="brush: php;">
&lt;?php
// Create a post type class for site posts
// To use as a bookmarking post type for sites you want to save/share.
class TypeSites {
    public $meta_fields = array( 'title', 'description', 'siteurl', 'category', 'post_tags' );

	public function TypeSites() {

        $siteArgs = array(
			'labels' =&gt; array(
                'name' =&gt; __( 'Sites', 'post type general name' ),
                'singular_name' =&gt; __( 'Site', 'post type singular name' ),
                'add_new' =&gt; __( 'Add New', 'site' ),
                'add_new_item' =&gt; __( 'Add New Site' ),
                'edit_item' =&gt; __( 'Edit Site' ),
                'new_item' =&gt; __( 'New Site' ),
                'view_item' =&gt; __( 'View Site' ),
                'search_items' =&gt; __( 'Search Sites' ),
                'not_found' =&gt;  __( 'No sites found in search' ),
                'not_found_in_trash' =&gt; __( 'No sites found in Trash' ),
			),
			'public' =&gt; true, 'show_ui' =&gt; true,
			'_builtin' =&gt; false,
			'capability_type' =&gt; 'post',
			'hierarchical' =&gt; false, // like 'post' not 'page'
			'rewrite' =&gt; array('slug' =&gt; 'site'), // Permalinks. Fixes a 404 bug
			'query_var' =&gt; 'site',
			'taxonomies' =&gt;  array('category', 'post_tag'), // Add tags and categories taxonomies
			'supports' =&gt; array( 'title', 'editor', 'author', 'comments' )
        );

        register_post_type( 'site', $siteArgs );	

	}

} // end of TypeSites{} class
?&gt;
</pre><p>Notice how the first function that has the post type registration code and stuff has the same name as the class itself. This is one way of creating the class <span
id="fixed">__construct()</span> method for the class, making it run automatically when the class is instantiated. I'll go over <span
id="fixed">__construct()</span> and <span
id="fixed">__destruct()</span> methods later on in more detail.</p><h2>Building The Class Methods</h2><p>In the next part of this series we will add some methods to this class, and really start to boogie down with some Object Oriented Php custom post types.</p><div
class="post-next"><a
href="/pro/WordPress-custom-post-types-object-oriented-series2">Continue To OOPost Types Classes Part 2 &raquo;</a></div><div
id="crp_related"><h3>Related Posts</h3><ul
class="relatedposts"><li><a
href="http://new2wp.com/pro/wordpress-custom-post-types-object-oriented-series2/" rel="bookmark" class="crp_title">OOPost Types: Methods Part 2 &#8211; Object Oriented WordPress 3.0 App</a></li><li><a
href="http://new2wp.com/pro/wp3-register-labels-update/" rel="bookmark" class="crp_title">Important Update: Register Taxonomies And Post Types With Labels</a></li><li><a
href="http://new2wp.com/pro/wordpress-custom-post-types-and-taxonomies-done-right/" rel="bookmark" class="crp_title">WordPress Custom Post Types And Taxonomies The Right Way</a></li><li><a
href="http://new2wp.com/pro/wordpress-custom-post-types-object-oriented-series3/" rel="bookmark" class="crp_title">OOPost Types: Objects Part 3 &#8211; Object Oriented WordPress 3.0 App</a></li><li><a
href="http://new2wp.com/rookie/codes-snippets-for-wordpress-3-0-new-features/" rel="bookmark" class="crp_title">15 Snippets To Prepare Your Theme For WordPress 3.0</a></li></ul></div><p><a
href="%%postur%%" target="_blank">OOPost Types: Classes Part 1 &#8211; Object Oriented WordPress 3.0 App</a></p><ul><li><a
href="http://twitter.com/home?status=OOPost Types: Classes Part 1 &#8211; Object Oriented WordPress 3.0 App http://new2wp.com/pro/wordpress-custom-post-types-object-oriented-series1/" rel="nofollow" title="Post this on Twitter" target="_blank">Post this on Twitter</a></li><li><a
href="http://facebook.com/share.php?u=http://new2wp.com/pro/wordpress-custom-post-types-object-oriented-series1/&title=OOPost Types: Classes Part 1 &#8211; Object Oriented WordPress 3.0 App" rel="nofollow" title="Post this on Facebook" target="_blank">Post this on Facebook</a></li><li><a
href="http://www.stumbleupon.com/submit?url=http://new2wp.com/pro/wordpress-custom-post-types-object-oriented-series1/&title=OOPost Types: Classes Part 1 &#8211; Object Oriented WordPress 3.0 App" rel="nofollow" title="Stumble This Post">Stumble This Post</a></li><li><a
href="http://del.icio.us/post?url=http://new2wp.com/pro/wordpress-custom-post-types-object-oriented-series1/&title=OOPost Types: Classes Part 1 &#8211; Object Oriented WordPress 3.0 App" rel="nofollow" title="Share this on del.icio.us" target="_blank">Share this on del.icio.us</a></li><li><a
href="http://digg.com/submit?phase=2&url=http://new2wp.com/pro/wordpress-custom-post-types-object-oriented-series1/&title=OOPost Types: Classes Part 1 &#8211; Object Oriented WordPress 3.0 App" rel="nofollow" title="Digg This Post" target="_blank">Digg This Post</a></li><li><a
href="http://thewebblend.com/submit?url=http://new2wp.com/pro/wordpress-custom-post-types-object-oriented-series1/&title=OOPost Types: Classes Part 1 &#8211; Object Oriented WordPress 3.0 App" rel="nofollow" title="Blend This!" target="_blank">Blend This!</a></li><li><a
href="http://designbump.com/submit?url=http://new2wp.com/pro/wordpress-custom-post-types-object-oriented-series1/&title=OOPost Types: Classes Part 1 &#8211; Object Oriented WordPress 3.0 App" rel="nofollow" title="DesignBump This" target="_blank">DesignBump This</a></li><li><a
href="http://www.designfloat.com/submit.php?url=http://new2wp.com/pro/wordpress-custom-post-types-object-oriented-series1/&title=OOPost Types: Classes Part 1 &#8211; Object Oriented WordPress 3.0 App" rel="nofollow" title="Post this on DesignFloat" target="_blank">Post this on DesignFloat</a></li></ul><p><a
href="http://new2wp.com"><img
src="http://tweeaks.com/wp-content/uploads/2010/08/new2wp-468x60px1.png" alt="New2WP" /></a></p><p><small>Copyright ©2010 <a
href="http://new2wp.com">New2WP.com</a>. Posted by jaredwilli on 2010 |<a
href="http://new2wp.com/pro/wordpress-custom-post-types-object-oriented-series1/">Permalink</a></p>]]></content:encoded> <wfw:commentRss>http://new2wp.com/pro/wordpress-custom-post-types-object-oriented-series1/feed/</wfw:commentRss> <slash:comments>4</slash:comments> </item> </channel> </rss>
<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk
Page Caching using disk (enhanced) (user agent is rejected)
Database Caching using disk

Served from: new2wp.com @ 2010-09-08 15:15:18 -->