Created
October 28, 2013 17:34
-
-
Save JiveDig/7201111 to your computer and use it in GitHub Desktop.
Genesis remove loop and create new loop. Add sticky post as first post
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//* 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) ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment