post

How to Display Posts from a Specific Category using Genesis Grid Loop

To display posts from a specific category or categories, you need to add a ‘cat’ argument to the $grid_args array. StudioPress gives a good introductory tutorial, How to Use the Genesis Grid Loop, on how to set this up.

In the StudioPress tutorial, you are given this example for your home.php.

<?php
remove_action( 'genesis_loop', 'genesis_do_loop' );
add_action( 'genesis_loop', 'child_grid_loop_helper' );
/** Add support for Genesis Grid Loop **/
function child_grid_loop_helper() {
    if ( function_exists( 'genesis_grid_loop' ) ) {
        genesis_grid_loop( array(
            'features' => 2,
            'feature_image_size' => 0,
            'feature_image_class' => 'alignleft post-image',
            'feature_content_limit' => 0,
            'grid_image_size' => 'grid-thumbnail',
            'grid_image_class' => 'alignleft post-image',
            'grid_content_limit' => 0,
            'more' => __( '[Continue reading...]', 'genesis' ),
            'posts_per_page' => 6,
            'cat' => '6,7' //enter your category IDs here separated by commas in ' '
        ) );
    } else {
        genesis_standard_loop();
    }
}
 
/** Remove the post meta function for front page only **/
remove_action( 'genesis_after_post_content', 'genesis_post_meta' );
 
genesis();
post

Custom Post Types, Post Formats, Custom Taxonomies, and Custom Fields and Meta Boxes

Understanding WordPress Custom Post Types
This is the new WordPress Soup: Custom Post Types, Post Formats, Custom Taxonomies, and Custom Fields/Meta Boxes. First and foremost, since we have already talked about what custom post types are, let’s define the other two: post formats and custom taxonomies.

Post Formats

Tapestry Theme - A Tumblog-Style Theme for WordPress using Post FormatsPost formats are not post types, that is, they are not content types. Instead, they are varying types of posts. They are posts with varying formatting. For example, consider the following:

  • a shared link should have a link as its focus.
  • a video should have a video as its focus, maybe its only content
  • an image should have an image as its focus, maybe again, its only content
  • a quote should have a quote as its focus, maybe its only content
  • Etc.

As Mark Jaquith states:

A Post Format is a formatting designation made to a post. For example, a post could be a short “aside,” or a Kottke.org-style link post, or a video post, or a photo gallery post. The data you input might be slightly different — video post should contain a video, an aside should probably not be very long, a link post should have a link. And the way that the post is displayed on the site might be very different — an aside will typically be displayed without a title, a link post may have the title point to the link. A video post may be wider, or have social sharing buttons auto-appended. But they’re all still posts. They still show up in your feed, and you still find them in the Posts section of the WordPress backend.

There are two major differences between custom post types and post formats. They are:

  1. Post formats will appear in the main RSS. Custom post types do not appear in the RSS feed by default without further coding (though in my opinion this should be part of the registration coding as it is with searching).
  2. Post formats are a WordPress “standardized convention.” In other words, instead of using categories to customize output and display (that may or may not be supported across themes/frameworks), post formats provides a standard method of doing this.

Simply, think Tumblr! StudioPress’s Tapestry Child Theme makes good use of Post Formats.

As far as WordPress is concerned, there are ONLY 10 Post Formats available to users/theme developers. They are:

  1. standard – regular post
  2. aside – Typically styled without a title. Similar to a Facebook note update.
  3. gallery – A gallery of images. Post will likely contain a gallery shortcode and will have image attachments.
  4. link – A link to another site.
  5. image – A single image.
  6. quote – A quotation. Probably will contain a blockquote holding the quote content. Alternatively, the quote may be just the content, with the source/author being the title.
  7. status – A short status update, similar to a Twitter status update.
  8. video – A single video.
  9. audio – An audio file. Could be used for Podcasting.
  10. chat – A chat transcript

Now, just like thumbnail images, post formats must be activated by the theme.

add_theme_support( 'post-formats' , array( 'aside' , 'chat' , 'gallery' , 'image' , 'link' , 'quote' , 'status' , 'video' , 'audio' ) );

To style post formats, use the following new CSS classes:

Standard: Normal CSS
Aside: .format-aside {}
Audio: .format-audio {}
Chat: .format-chat {}
Gallery: .format-gallery {}
Image: .format-image {}
Link: .format-link {}
Quote: .format-quote {}
Status: .format-status {}
Video: .format-video {}

Custom Taxonomies

Think Categories and Tags. These both represent two types of taxonomies: hierarchical, where terms can have a parent-child relationship (e.g.,categories) and non-hierarchical, where all terms are equal (e.g., tags). Custom taxonomies give you the ability to name and create taxonomies that act like Tags and Categories but are named whatever you’d like to name them.

Other built-in taxonomies include Link Category and Nav Menu. So what are some custom taxonomies? These can be determined by custom post types and can be whatever you need them to be; for example, an employee custom post type could use an employee departments hierarchical taxonomy. Another example could be a movie custom post type utilizing multiple taxonomies of genre, director, stars/actors, etc. (More information forthcoming…)

Custom Fields and Meta Boxes

These are designated areas to input information on a per post/custom post (or content entry) basis. Generally speaking, if the Title, Editor, etc. that is found on a post won’t do what you want it to do with the content, then most people add custom fields that creates an easy way to input content as well as display the content. Custom Meta Boxes and Custom Fields are sets of additional editable fields that may be added to any post type, whether page, post, or a custom post type. The custom fields can be used to store any sort of content/data that you want. They are often single line input boxes, checkboxes, dropdown boxes, paragraph text areas, radio buttons, etc. There will be more on this later as Custom Meta Boxes and Custom Fields are usually extremely important to Custom Post Types. (More information forthcoming…)

Summary

So, in short, custom post types are content types for custom storing with custom displays on the backend and front end. Post formats are types or variations of displaying content on the front end only coming with a standardize set of 10 choices. Custom taxonomies are terms, whether hierarchical or not, that are used for organizing content. Custom Meta Boxes and Fields are designated areas to add more information beyond the standard title, editor, etc. (which are displayed via built-in meta boxes).

More Information/Further Reading

Post Formats Links

Custom Taxonomies Links

Other

post

Benefits and Advantages of Using Custom Post Types

Understanding WordPress Custom Post Types

It’s really funny that the results of a basic search on the internet for the benefits of custom post types is scarce on the benefits or the advantages of custom post types. To me and I believe to the whole WordPress community, the benefits of custom post types are dramatic! The benefits and advantages of custom post types are innumerable and exponential. (If you don’t know what Custom Post Types are, see my previous post: Understanding WordPress Custom Post Types: What Are Custom Post Types?.)

So here are five benefits and advantages of using custom post types or rather, here are five reasons why you should use custom post types:

  1. Custom display of content: custom post types allow for content to be entered and displayed in a custom manner that is content-centered and content-focused.
  2. Hide content from default queries: It’s not that you are hiding content per se; however, out of the box, custom post types are not included in the query further customizing the ability to organize and present the content the way you want. Without additional coding, custom post types are not included in the default queries. Furthermore, the customization options allowed in registering custom post types further increases the beauty and power of custom post types by making them non-public and non-queryable.
  3. Ability to manage content: on the backend, custom post types streamline writing and organization
  4. Improved usability: simply it is quite complex to tell a client, “To post a podcast, you must do A, B, C, and D. To post a blog post, you must do A, B, and C.” Custom post types allow you to create one singular process that makes sense to the non-programmer and non-power user.
  5. Increases productivity and efficiency: now
  6. Increases site security: it will eliminate third party plugins further strengthening your security (or rather eliminating dependency on a third party that could potentially open a vulnerability).

So let’s think about this for a minute. How does custom post types increase productivity?

As Konstantin points out, consider this scenario:

For instance, why should the Edit Post page contain the ability to attach an audio file if it won’t be used 50% of the time? Or why would Quotes contain post revisions? Chats and Video posts wouldn’t require image posting, right? This way you can talk to your client or content manager in a certain way:

John, could you please add a new Podcast? Here’s the MP3 file.

Instead of

John, I need you to add this MP3 file as a Podcast – please add a new post, then in the box on the right you should pick that your post type is a Podcast, then a little bit lower in the next box you should upload this audio file, and also please make sure that you check the Podcasts category before you publish.

No, John, don’t touch the Video box, we use that for video posts. No, leave the custom fields as they are, you should never touch that area.

So, now you don’t have to rely on categories. You don’t have to filter categories here or there to get the pages that you want. Posting becomes simple and easy. Displaying content becomes streamlined and custom. The backend can be further customized. No more wasted space in the database or the post page. No more wasted landscape in the backend. No need to explain complicated custom fields. Everything becomes straight forward and simple.

Simply, custom post types help you CUSTOMIZE and ORGANIZE your CONTENT in order to PRESENT it in a better manner (than simply high-jacking and even abusing categories or having to explain custom fields again and again). Before the popularization and the simplification of custom post types, developers were stuck with using custom fields and categories and had to give detailed, robust instructions which often times led to confusion (and possibly the breaking of the site altogether). Not only can custom post types be wrapped around your content, it is molded to your data, your needs, and your goals, whatever they may be. It will make things easier to manage, create, edit, etc. It will increase productivity, efficiency, and even usability.

What benefits or advantages do you see about custom post types?

post

How to Find Out What Shortcodes Are Active

I came across this neat little tidbit while trying to debug a shortcode to determine shortcode conflict, and I wanted to share with everyone. To find out what shortcodes are active on your site, use this simple code:

global $shortcode_tags;
echo "<pre>"; print_r($shortcode_tags); echo "</pre>";
post

What Are Custom Post Types?

Understanding WordPress Custom Post Types

Understanding WordPress Custom Post Types
When I first heard about custom post types (CPTs) less than a year ago when I was introduced to WordPress 3.0 (even though they’ve been around since 2005), I thought that custom post types would change, revolutionize WordPress making it more than a blogging platform, more than a content management system (CMS). And it has and will continue to change how web WordPress developers develop, if they haven’t already. However, it took me longer to understand custom post types than I had expected, primarily because of my lack of proximity and “need” for them. Yet my lack of “need” for them was because I learned how to highjack categories to make WordPress do what I wanted. However, my lack of need for them was only driven by my lack of understanding them. Instead of “hacking” or manipulating categories or tags to do the leg work, custom post types can do the customized work for you, quickly, easily, and simply.

What are Custom Post Types NOT?

Custom post types are not just “blog posts” in the traditional sense for “post” is one post type. They are not a replacement for custom fields for custom post types work in tandem with custom fields. They are not taxonomies for custom post types are associated with taxonomies and vice versa. Creating custom post types are not completely GUI (Graphical User Interface) driven innately (or out of the box) in WordPress. However, with some premium plugins like Easy Content Types and GD Custom Posts And Taxonomies Tools as well as some “free” plugins like Custom Post Types UI Plugin and WP Easy Post Types, custom post types graphical user interfacing has made great strides in what could easily be incorporated into WordPress core, if Automattic so choses to move towards a more GUI approach.

What ARE Custom Post Types?

First up, to clear some misconceptions, Custom Post Types should be really be called Custom Content Types. As Mark Jaquith aptly says (and even admits):

These [Custom Post Types] were poorly named. Think: Custom Content Types. That is, non-post content. Examples: employees, products, attachments, menu items, pages, pets. If you want it to show up in your site’s main RSS feed, then it’s probably not a custom post type.

Instead, custom post types are “content” types. A page is a post type. A post is a post type. They can be used to store information or data and/or administer, arrange or display different types of content on the site. WordPress uses various post types: pages, posts, revisions, attachments, and nav menus, of which custom post types stand along side.

  1. Posts: default content type for blog posts displayed in reverse sequential order by post time
  2. Pages: default content type for static pages which can use page templates and organized via hierarchical structure
  3. Attachments: default content type for images, etc
  4. Revisions: default content type for post, etc., revisions
  5. Nav Menus: default content type for the custom nav menu
  6. Custom Post Types (Custom Content Types): Can be whatever we want, define, and set, e.g., events, podcasts, movies, cars, etc.

Thinking “custom content types” when someone says “custom post types” avoids the confusion with WordPress’s posts. Some custom post type examples include:

  • Media (e.g., galleries, links, micro-blogs, movies, videos, podcasts, portfolios, music, etc.)
  • People (e.g., authors, employees, movie stars, producers, etc.)
  • Products (e.g., cars, computers, real estate/properties, recipes, books, etc.)
  • Events (e.g., any sort that includes date, time, cost, location, directions, etc.)
  • Places (e.g., locations, resorts, etc.)
  • Online Store (e.g., retail, wholesale, etc.)

Simply it is or can be anything that can be better arranged that isn’t a “post” or a “page.” Just think about those things that we all too often thought, “There’s got to be a better way to present this information than a page or a post!” Custom post types should be something custom. It should have a custom submission area with specific meta content (via custom meta boxes and custom fields). The submission area should look and feel different from a normal post or page submission area.

For more information stay tuned. Until then, consider these posts:

Helpful Links:

  1. WordPress Codex: Custom Post Types
  2. WordPress Codex: Register Post Type
  3. Custom Post Types in WordPress
  4. How to Create a WordPress Custom Post Type Template in .Genesis Framework
  5. Submit Post Form for WordPress Custom Post Type
post

Slight Upgrade/Revision to WP-Cycle to Allow Page IDs

One thing that has bugged me about WP-Cyle is that I had to include hard-coded URLs to linkify the rotating images. This is problem matic when I change my URLs, etc. So I just want to enter page IDs and allow WordPress to properly assign the proper URL. Download the revised/upgraded WP Cycle: WP Cycle Alternative (152).

For those who want to know what I did, here’s what I added:

On line 393, the original code contains:

if($value['image_links_to'])
$input[$key]['image_links_to'] = clean_url($value['image_links_to']);

I changed it to:

if($value['image_links_to']) {
	$checkhttp = substr($value['image_links_to'], 0, 4);
	if ($checkhttp == 'http')
		$input[$key]['image_links_to'] = clean_url($value['image_links_to']);
}

Then on line 416 in the foreach section, the original code contains:

foreach((array)$wp_cycle_images as $image => $data) {
	if($data['image_links_to'])
	echo '<a href="'.$data['image_links_to'].'">';
	
	echo '<img src="'.$data['file_url'].'" width="'.$wp_cycle_settings['img_width'].'" height="'.$wp_cycle_settings['img_height'].'" class="'.$data['id'].'" alt="" />';
	
	if($data['image_links_to'])
	echo '</a>';
	
	echo $newline;
}

I changed it to:

foreach((array)$wp_cycle_images as $image => $data) {
	if($data['image_links_to']) {
		$checkhttp = substr($data['image_links_to'], 0, 4);
		if ($checkhttp != 'http') {
			$id = intval($data['image_links_to']);
			$data['image_links_to'] = get_permalink( $id );
		}
		echo '<a href="'.$data['image_links_to'].'">';
	}
	
	echo '<img src="'.$data['file_url'].'" width="'.$wp_cycle_settings['img_width'].'" height="'.$wp_cycle_settings['img_height'].'" class="'.$data['id'].'" alt="" />';
	
	if($data['image_links_to'])
	echo '</a>';
	
	echo $newline;
}