JiveDig
10/28/2013 - 5:34 PM

Genesis remove loop and create new loop. Add sticky post as first post

Genesis remove loop and create new loop. Add sticky post as first post

//* Replace the standard loop with our custom loop
//* props to David Wang, he is the man!
// @author David Wang
// @link http://genesissnippets.com/genesis-custom-loop/
 
remove_action( 'genesis_loop', 'genesis_do_loop' );

add_action( 'genesis_loop', 'child_do_sticky_post', 5 );
function child_do_sticky_post() {
 
    global $paged; // current paginated page
    global $query_args; // grab the current wp_query() args
    $exclude_ids = '143';
    $args = array(
		'paged' 		 		=> $paged, // respect pagination
        'post_type'		 		=> 'staff',
		'post__in'			=> array( 143 ),
    );
 
    genesis_custom_loop( wp_parse_args($query_args, $args) );
 
}

add_action( 'genesis_loop', 'child_do_custom_loop', 10 );
function child_do_custom_loop() {
 
    global $paged; // current paginated page
    global $query_args; // grab the current wp_query() args
    $args = array(
		'paged' 		 		=> $paged, // respect pagination
        'post_type'		 		=> 'staff',
		'post__not_in'			=> array( 143 ),
        'orderby'			 	=> 'title',
        'order'		 			=> 'ASC',
    );
 
    genesis_custom_loop( wp_parse_args($query_args, $args) );
 
}