Created
September 6, 2020 19:41
-
-
Save sabrina-zeidan/b27923623fc2839e8c401a14043e266b to your computer and use it in GitHub Desktop.
Html wrapper for WP_Query (insert text before or after the loop)
This file contains 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
<?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