Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Html wrapper for WP_Query (insert text before or after the loop)
<?php
//Handy when CPT previews are used in different templates across the site
add_action( 'loop_start', 'recipes_loop_start' );
function recipes_loop_start( $query ){
if ( !$query->is_main_query() && $query->get('post_type')== 'recipe' && !is_admin()) echo "<ul class='recipes-preview'>";
}
add_action( 'loop_end', 'recipes_loop_end' );
function recipes_loop_end( $query ){
if ( !$query->is_main_query() && $query->get('post_type')== 'recipe' && !is_admin()) echo "</ul>";
}a
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.