Skip to content

Instantly share code, notes, and snippets.

@srdjan-m
Created January 28, 2020 16:56
Show Gist options
  • Save srdjan-m/e82bbdf8d706858dcf1b9c36ea6dbd9e to your computer and use it in GitHub Desktop.
Save srdjan-m/e82bbdf8d706858dcf1b9c36ea6dbd9e to your computer and use it in GitHub Desktop.
genesis: replace default loop with custom loop https://www.genesissnippets.com/2012/09/15/genesis-custom-loop/ Genesis comes with a handy function called genesis_custom_loop(). It’s an easy way for you to create a new loop without having to write all the code to create a new loop with WP_Query manually. Here’s how you can use it in your theme. T…
/** Replace the standard loop with our custom loop */
remove_action( 'genesis_loop', 'genesis_do_loop' );
add_action( 'genesis_loop', 'child_do_custom_loop' );
function child_do_custom_loop() {
global $paged; // current paginated page
global $query_args; // grab the current wp_query() args
$args = array(
'category__not_in' => 42, // exclude posts from this category
'paged' => $paged, // respect pagination
);
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