Site icon WP Smith

How to Effectively Use the Blog Template with the Genesis Easter Egg, query_args, Pt 2?

In my previous post, How to Effectively Use the Blog Template with the Genesis Easter Egg, query_args, I discussed how to create single category pages and single custom post type pages with a caveat explained how to use shortcodes to get the desired content as well as the look and feel that you want.

However, if you wanted to get a bit more fancy like integrating multiple custom post types or multiple categories, that can be a bit more complicated. However, it isn't, if you know how to use query_args and query strings. With multiple categories, WordPress is looking for a comma separated (with no spaces!) list of categories. Your query_args would be: cat=3,7.

However, this will not work with post types! Instead you need to "build an array of post types via query string." Your query_args would be: post_type[]=post&post_type[]=wps_cpt1&post_type[]=wps_cpt2

So, if you wanted to combine the query where you show only posts from the post post type and your custom post type that share a specific category (WordPress built-in categories), then your query_args would be: cat=3&post_type[]=post&post_type[]=wps_cpt1.

So, when I said "your possibilities are almost endless" with using the Genesis Easter Egg, I meant that your possibilities are almost endless!