WP Smith

Creating WordPress & Genesis Websites Since 2010

  • Home
  • About
  • Services
  • Blog
  • Contact

Jun 01 2011

Genesis Grid Loop: How to Set Features to a Specific Category and Non-Features/Grid Posts to a Separate (Another) Category

In order to set your Genesis Grid Loop 'features', which are the number of posts that will show at the top of the page when using the Grid Loop, to one specific category or categories and the non-features or grid posts to another category or set of categories, you will need to adjust your grid_loop_helper function.

Here is a simple way of displaying posts via categories via the Grid loop calling genesis_grid_loop() twice.
[php highlight="15-16, 29-30, 33-39"]function child_grid_loop_helper() {
global $paged;
if ( function_exists( 'genesis_grid_loop' ) ) {
//set featured grid_args
$grid_args_featured = array(
'features' => 1,
'feature_image_size' => 'child_full',
'feature_image_class' => 'aligncenter post-image',
'feature_content_limit' => 100,
'grid_image_size' => 'child_thumb',
'grid_image_class' => 'aligncenter post-image',
'grid_content_limit' => 0,
'more' => '',
'posts_per_page' => 1,
'post_type' => 'books_fbd',
'cat' => '8',
'paged' => $paged
);
//set non-featured grid_args
$grid_args_rest = array(
'features' => 0,
'feature_image_size' => 'child_full',
'feature_image_class' => 'aligncenter post-image',
'feature_content_limit' => 100,
'grid_image_size' => 'child_thumb',
'grid_image_class' => 'aligncenter post-image',
'grid_content_limit' => 0,
'more' => '',
'posts_per_page' => 4,
'post_type' => 'books_fbd',
'cat' => '7',
'paged' => $paged
);

//assuming that features won't go beyond 1 page
if ( ($grid_args_featured['paged'] > 1) || ($grid_args_past['paged'] > 1) )
genesis_grid_loop( $grid_args_rest ); //do not show featured after page 1
else {
genesis_grid_loop( $grid_args_featured );
genesis_grid_loop( $grid_args_rest );
}

} else {
genesis_standard_loop();
}
} [/php]

However, I have posted on the StudioPress forums, which creates another argument for 'features_cat' suggesting some edits for the genesis_grid_loop() function.

Written by Travis Smith · Categorized: Genesis, Genesis Grid Loop, Tutorials

May 31 2011

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 highlight="17"]<?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();[/php]

Written by Travis Smith · Categorized: Genesis, Genesis Grid Loop, Tutorials

May 31 2011

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.

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

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

  • Otto: Post types and formats and taxonomies, oh my!
  • Andrew Nacin: On standardized post formats
  • WPBeginner: What, Whys, and How to’s of Post Formats in WordPress 3.1
  • Mark Jaquith: Post Formats vs. Custom Post Types
  • Lisa Sabin-Wilson: WordPress 3.1 Post Formats Reference
  • WordCast: WordPress Post Formats Tutorial: Add Tumblr Style Features To Your Blog with WordPress 3.1
  • WP Engineer: Post Formats – More Creative Ways For A Theme
  • Flashing Cursor: Intro to Post Formats in WordPress 3.1

Custom Taxonomies Links

  • Tammy Hart: Custom Post Types and Taxonomies
  • net tuts+: Introducing WordPress 3 Custom Taxonomies
  • 1WD.CO: The Essential Guide to WordPress 3.0 Custom Taxonomies
  • WP Dad: A Short Introduction to WordPress 3.0 for Beginners

Other

  • WordPress Theming: Custom Post Type Resources

Written by Travis Smith · Categorized: Custom Post Types

May 30 2011

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?

Written by Travis Smith · Categorized: Custom Post Types

May 29 2011

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:
[php]global $shortcode_tags;
echo "<pre>"; print_r($shortcode_tags); echo "</pre>";
[/php]

Written by Travis Smith · Categorized: WordPress

  • « Previous Page
  • 1
  • …
  • 40
  • 41
  • 42
  • 43
  • 44
  • …
  • 61
  • Next Page »
  • Twitter
  • Facebook
  • LinkedIn
  • Google+
  • RSS

Copyright © 2025 ďż˝ WP Smith on Genesis on Genesis Framework ďż˝ WordPress ďż˝ Log in