{"id":11481,"date":"2010-12-12T16:17:06","date_gmt":"2010-12-12T16:17:06","guid":{"rendered":"https:\/\/wordpress.org\/plugins-wp\/portico\/"},"modified":"2013-02-18T21:32:37","modified_gmt":"2013-02-18T21:32:37","slug":"portico","status":"closed","type":"plugin","link":"https:\/\/wordpress.org\/plugins\/portico\/","author":7413713,"comment_status":"closed","ping_status":"closed","template":"","meta":{"version":"1.0.2","stable_tag":"1.0.2","tested":"3.5.2","requires":"3.0","requires_php":"","requires_plugins":"","header_name":"Portico","header_author":"Dan Bettles <dan@danbettles.net>","header_description":"","assets_banners_color":"","last_updated":"2013-02-18 21:32:37","external_support_url":"","external_repository_url":"","donate_link":"http:\/\/danbettles.net\/","header_plugin_uri":"http:\/\/danbettles.net\/software\/portico\/","header_author_uri":"http:\/\/danbettles.net\/","rating":0,"author_block_rating":0,"active_installs":0,"downloads":1375,"num_ratings":0,"support_threads":0,"support_threads_resolved":0,"author_block_count":0,"sections":["description","installation","faq","changelog"],"tags":[],"upgrade_notice":[],"ratings":{"1":0,"2":0,"3":0,"4":0,"5":0},"assets_icons":[],"assets_banners":[],"assets_blueprints":{},"all_blocks":[],"tagged_versions":["1.0.0","1.0.1","1.0.2"],"block_files":[],"assets_screenshots":{"screenshot-2.png":{"filename":"screenshot-2.png","revision":"1444231","resolution":"2","location":"plugin"},"screenshot-1.png":{"filename":"screenshot-1.png","revision":"1444231","resolution":"1","location":"plugin"}},"screenshots":{"1":"The admin interface created by Portico for the \"podcast\" custom post-type described in the example.  Podcasts are accessed via a link in the left-hand menu; permalinks contain the slug \"podcast\"; the custom type's fields appear in a section underneath the main content editor.","2":"Output from the display template for the \"podcast\" custom post-type described in the example."},"jetpack_post_was_ever_published":false},"plugin_section":[],"plugin_tags":[225,25179,19996,50026,50027,1794,1487,11491,50025,4069,22280,38022,47171,50024],"plugin_category":[],"plugin_contributors":[],"plugin_business_model":[],"class_list":["post-11481","plugin","type-plugin","status-closed","hentry","plugin_tags-cms","plugin_tags-content-type","plugin_tags-content-types","plugin_tags-contenttype","plugin_tags-contenttypes","plugin_tags-custom-post-type","plugin_tags-custom-post-types","plugin_tags-custom-posttype","plugin_tags-custom-posttypes","plugin_tags-custom-type","plugin_tags-custom-types","plugin_tags-php-5-3","plugin_tags-phpunit","plugin_tags-wordpress-3","plugin_committers-danbettles"],"banners":[],"icons":{"svg":false,"icon":"https:\/\/s.w.org\/plugins\/geopattern-icon\/portico.svg","icon_2x":false,"generated":true},"screenshots":[{"src":"https:\/\/ps.w.org\/portico\/trunk\/screenshot-1.png?rev=1444231","caption":"The admin interface created by Portico for the \"podcast\" custom post-type described in the example.  Podcasts are accessed via a link in the left-hand menu; permalinks contain the slug \"podcast\"; the custom type's fields appear in a section underneath the main content editor."},{"src":"https:\/\/ps.w.org\/portico\/trunk\/screenshot-2.png?rev=1444231","caption":"Output from the display template for the \"podcast\" custom post-type described in the example."}],"raw_content":"<!--section=description-->\n<h4>Overview<\/h4>\n <p>There are just two steps to implementing a custom post-type with Portico.  Here's a quick overview before we get down to the coding required.<\/p>\n <ul>\n<li>Declare a class that defines your custom post type.<\/li>\n<li>Create a display template for the new post type.  <\/li>\n<\/ul>\n <p>That's it!  Portico handles the rest for you, and that includes building an admin interface for working with posts of the new type.<\/p>\n <h4>Coding<\/h4>\n <p>Let's take a look at a simple example, the implementation of a Podcast post-type.<\/p>\n <p>Here's what the custom post-type's definition looks like:<\/p>\n <pre><code>&lt;?php  \/**  * Podcast custom post-type implemented using the Portico plugin  *\/ class Podcast extends \\portico\\CustomPostType {     protected function setUp()     {         \/\/At present, \"mandatory\" simply marks the field as mandatory in the admin interface         $this-&gt;addCustomField('artist', 'Artist', array(             'mandatory' =&gt; true,         ));          \/\/Default values can also be applied to text fields         $this-&gt;addCustomField('genre', 'Genre', array(             'values' =&gt; array(                 'Ambient' =&gt; 'Ambient',                 \"Drum 'n' Bass\" =&gt; \"Drum 'n' Bass\",                 'Dubstep' =&gt; 'Dubstep',             ),             'default' =&gt; \"Drum 'n' Bass\",         ));          \/\/Set \"length\" to NULL to get a textarea         $this-&gt;addCustomField('trackList', 'Track List', array(             'length' =&gt; null,         ));     } } ?&gt; <\/code><\/pre>\n <p>Put the code in <code>functions.php<\/code> - or in a separate file <em>include<\/em>d by <code>functions.php<\/code> - in your theme.<\/p>\n <p>The next time you visit the WordPress admin area you should see a \"Podcasts\" section in the left-hand menu, beneath the usual \"Posts\" and \"Pages\" links.  Take a look at the first screenshot to see exactly what you can expect.<\/p>\n <p>All that remains is to create a custom display-template so we can view the values of a podcast's custom fields.<\/p>\n <p>You can start by making a copy of <code>single.php<\/code> and renaming it after your custom post-type.  Here's the template for the Podcast type, based on <code>single.php<\/code> shipped with the Modern Clix 1 theme:<\/p>\n <pre><code>&lt;?php get_header() ?&gt;  &lt;div id=\"content\" class=\"col span-8\"&gt;  &lt;?php if (have_posts()) : ?&gt;      &lt;div class=\"col last span-6 nudge-2\"&gt;         &lt;h4 class=\"ver small\"&gt;You are reading&lt;\/h4&gt;  \n    &lt;\/div&gt;      &lt;?php while (have_posts()) : the_post() ?&gt;         &lt;?php $podcast = new Podcast($post, get_post_custom(get_the_ID())) ?&gt;      &lt;div class=\"post\"&gt;         &lt;div class=\"post-meta col span-2\"&gt;             &lt;ul class=\"nav\"&gt;                 &lt;li&gt;Artist: &lt;?php echo $podcast-&gt;getSingleCustomFieldValue('artist') ?&gt;&lt;\/li&gt;                 &lt;li&gt;Genre: &lt;?php echo $podcast-&gt;getSingleCustomFieldValue('genre') ?&gt;&lt;\/li&gt;             &lt;\/ul&gt;         &lt;\/div&gt;          &lt;div class=\"post-content span-8 nudge-2\"&gt;             &lt;h3&gt;&lt;a href=\"&lt;?php the_permalink() ?&gt;\" rel=\"bookmark\" title=\"Permanent Link to &lt;?php the_title_attribute() ?&gt;\"&gt;&lt;?php the_title() ?&gt;&lt;\/a&gt;&lt;\/h3&gt;              &lt;?php the_content('Continue reading...') ?&gt;              &lt;p&gt;&lt;?php echo nl2br($podcast-&gt;getSingleCustomFieldValue('trackList')) ?&gt;&lt;\/p&gt;         &lt;\/div&gt;     &lt;\/div&gt;      &lt;?php comments_template() ?&gt;      &lt;?php endwhile ?&gt;  &lt;?php else : ?&gt;      &lt;h3&gt;Post Not Found&lt;\/h3&gt;      &lt;p&gt;Sorry, but you are looking for something that isn't here.&lt;\/p&gt;  &lt;?php endif ?&gt;  &lt;\/div&gt;  &lt;hr \/&gt;  &lt;?php get_sidebar() ?&gt; &lt;?php get_footer() ?&gt; <\/code><\/pre>\n <p>Important to note here is the line that creates an instance of your custom post type, <code>&lt;?php $podcast = new Podcast($post, get_post_custom(get_the_ID())) ?&gt;<\/code>. It's from this instance that we get the values of the custom fields.<\/p>\n <p>Take a look at the second screenshot to see what you can expect from this template.<\/p>\n\n<!--section=installation-->\n<p><strong>N.B. Portico requires PHP 5.3.<\/strong><\/p>\n <ol>\n<li>Install the plugin under the <code>\/wp-content\/plugins\/<\/code> directory.<\/li>\n<li>Activate the plugin through the \"Plugins\" menu in WordPress.<\/li>\n<\/ol>\n <p>Follow the instructions on the Description tab to get started creating custom post-types with Portico.<\/p>\n\n<!--section=faq-->\n<h4>My WordPress site is running on a version of PHP older than PHP 5.3.  Why does Portico not work?<\/h4>\n <p>Portico requires PHP 5.3.<\/p>\n <h4>I receive a 404 when trying to view a Portico custom post type.  What gives?<\/h4>\n <p>Try logging-in to, and then logging-out of, the admin area.  This should force WordPress to regenerate its URL rewriting rules, which could be the source of the problem.<\/p>\n\n<!--section=changelog-->\n<p>N\/A<\/p>","raw_excerpt":"Portico makes defining and administering custom post-types EASY.  Define your post-type in a class, and an admin\ninterface will be created for you.","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin\/11481","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin"}],"about":[{"href":"https:\/\/wordpress.org\/plugins\/wp-json\/wp\/v2\/types\/plugin"}],"replies":[{"embeddable":true,"href":"https:\/\/wordpress.org\/plugins\/wp-json\/wp\/v2\/comments?post=11481"}],"author":[{"embeddable":true,"href":"https:\/\/wordpress.org\/plugins\/wp-json\/wporg\/v1\/users\/danbettles"}],"wp:attachment":[{"href":"https:\/\/wordpress.org\/plugins\/wp-json\/wp\/v2\/media?parent=11481"}],"wp:term":[{"taxonomy":"plugin_section","embeddable":true,"href":"https:\/\/wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_section?post=11481"},{"taxonomy":"plugin_tags","embeddable":true,"href":"https:\/\/wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_tags?post=11481"},{"taxonomy":"plugin_category","embeddable":true,"href":"https:\/\/wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_category?post=11481"},{"taxonomy":"plugin_contributors","embeddable":true,"href":"https:\/\/wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_contributors?post=11481"},{"taxonomy":"plugin_business_model","embeddable":true,"href":"https:\/\/wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_business_model?post=11481"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}