So I was creating page templates that called for a custom loop for specific categories that I blocked from my blog in my Genesis Settings. To do this, use this page template.
You do not need to use 'cat' which requires the category ID; however, it is always my preference. You can also choose from wp_query:
- cat (int) - use category id.
- category_name (string) - use category slug (NOT name).
- category__and (array) - use category id.
- category__in (array) - use category id.
- category__not_in (array) - use category id.
[php]
<?php
/**
*
* Template Name: Projects
* This file handles blog posts with the category Projects within a page.
*
*/
remove_action('genesis_loop', 'genesis_do_loop');
add_action('genesis_loop', 'custom_do_cat_loop');
function custom_do_cat_loop() {
global $query_args; // any wp_query() args
$args= array('cat' => '30');
genesis_custom_loop(wp_parse_args($query_args, $args));
}
genesis();
[/php]
Duncan says
Hi, you’ve written an extremely helpful post here.
I had a (hopefully) simple question though regarding the display of category’d posts on a custom template page.
I’ve successfully managed to create custom template pages that call the specific posts of a specific category on them, however the site I am working with is one that has many posts in each relevant category. I am aiming to build a custom template page that will display only a titled-link and thumbnail of the featured image to the posts with a certain category, having the link and thumbnail link take the user to the specific post of that given category. This will keep clutter down and keep those older posts relevant and viewable (as opposed to burying them 30 pages deep because each FULL post is displayed rather than a link to it).
Surprisingly i’ve dug around and cannot find any information on this within the Genesis framework. The idea is a page that displays links, like an archive, to posts of a specific category (that I define).
Any ideas would be GREATLY appreciated! Thanks, and again, good information here
Travis Smith says
Hi, you probably want to investigate Display Posts by Bill Erickson.
Matt says
Hey Travis,
Just wanted to drop you a quick line to say thank you for all the work you have done supporting the WordPress / Genesis community. I have been reading your site for several, several months now off and on and you have helped me out tremendously.
I have used this post and related other posts specifically to help me do various things on my own site
Thank you and keep up the good work bro. I really do appreciate it.
Regards,
Matt
Terence says
HI Travis,
Brad Dalton send me in your direction because I am trying to figure out how to use the loop in Genesis to integrate a plugin ~ which Duncan (above) can use, I think ~ to integrate Cornerstone content instead of simply running a blog with all the posts in it.
I want to get rid of the separate blog altogether and integrate all posts using the site’s structure to place them in the correct cornerstone sections.
I am new to Genesis so I am having difficulties tracking down how the loop works exactly, which is why I ended up here.
The loop is generally started with the following code:
[php]
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
[/php]
For working with posts, I want to organize this new site’s content into “sections” using the Cornerstone plugin [ http://wordpress.org/extend/plugins/cornerstone/ ] and not fake the site structure with categories and tags, so I want to use a couple different functions in place of the default ones:
[php]
<?php if ( cnr_have_children() ) : while ( cnr_have_children() ) : cnr_next_child(); ?>
[/php]
In the loop, displaying the post’s content should be exactly the same as with any other template in a theme. So I assume I can use template tags such as [php]the_title(), the_excerpt(),[/php] etc.
Here’s an example loop that displays the title and an excerpt with a link for each post in the section when using Cornerstone…
[php]
<?php if ( cnr_have_children() ) : while ( cnr_have_children() ) : cnr_next_child(); ?>
<h3><?php the_title(); ?></h3>
<div><?php the_excerpt(); ?></div>
<?php endwhile; endif; ?>
[/php]
So my questions are ~
A) how is this form of post structuring likely to affect (or not) the loop and other functions within Genesis in general, and more specifically in Dynamik for Genesis?, and
B) where does the loop start in Genesis?
C) Can I simply use a Dynamik Custom Hook Box with “genesis_loop” to replace the Genesis loop entirely and not worry about A) & B) ?
Any ideas?
Terence.
Travis Smith says
Hello Terence,
You are asking several questions here. If you are dealing with a single post page, your structure is simple and straight forward. Here is a sample single post page with the hooks. To look at the Framework, Nick has a great series called Genesis Explained. I hope that helps.
Terence says
Hi Travis,
In the intervening period, the entire population of China lost its chance of democracy, the European economy collapsed to an all time low and I gave up struggling with Genesis 1.x.
Here’s hoping the coming months will be a little more positive for us all.