function recipe_hero_shortcode_single_display($id) { if (!$id) { echo 'You need to include the ID attribute!'; } else { // Enqueue Lightbox if (get_option('recipe_hero_enable_lightbox') == '' || get_option('recipe_hero_enable_lightbox') == 'yes') { wp_enqueue_script('magnific'); wp_enqueue_script('rh-lightbox'); wp_enqueue_style('magnific-css'); } // We don't want recipe comments / reviews in a shortcode remove_action('recipe_hero_after_single_recipe', 'recipe_hero_output_single_comments', 10); $args = array('post_type' => 'recipe', 'posts_per_page' => 1, 'p' => $id); $the_query = new WP_Query($args); if ($the_query->have_posts()) { while ($the_query->have_posts()) { $the_query->the_post(); echo '<div class="recipe-hero">'; echo recipe_hero_get_template_part('content', 'single-recipe'); echo '</div>'; } wp_reset_postdata(); } else { } } }
function recipe_hero_shortcode_archive_display($per_page, $orderby, $order, $ids, $course, $cuisine) { $args = array('post_type' => 'recipe', 'posts_per_page' => $per_page, 'orderby' => $orderby, 'order' => $order); if ($ids) { $ids_explode = explode(', ', $ids); $args['post__in'] = $ids_explode; } if ($course || $cuisine) { $args['tax_query'] = array('relation' => 'AND', $course ? array('taxonomy' => 'course', 'field' => 'slug', 'terms' => $course) : false, $cuisine ? array('taxonomy' => 'cuisine', 'field' => 'slug', 'terms' => $cuisine) : false); } $the_query = new WP_Query($args); if ($the_query->have_posts()) { while ($the_query->have_posts()) { $the_query->the_post(); echo '<div class="recipe-hero">'; echo recipe_hero_get_template_part('content', 'archive-recipe'); echo '</div>'; } wp_reset_postdata(); } else { _e('No recipes have been found!', 'recipe-hero'); } }
<?php global $wp_query; ?> <?php if (have_posts()) { ?> <?php while (have_posts()) { the_post(); ?> <?php recipe_hero_get_template_part('content', 'archive-recipe'); ?> <?php } // end of the loop. ?> <?php /** recipe_hero_after_main_loop hook * * @hooked recipe_hero_output_loop_pagination - 10 */ do_action('recipe_hero_after_main_loop'); ?>
<?php /** * recipe_hero_before_main_content hook * * @hooked */ do_action('recipe_hero_before_main_content'); ?> <?php while (have_posts()) { the_post(); ?> <?php recipe_hero_get_template_part('content', 'single-recipe'); ?> <?php } // end of the loop. ?> <?php /** * recipe_hero_after_main_content hook * * @hooked recipe_hero_output_content_wrapper_end - 10 (outputs closing divs for the content) */ do_action('recipe_hero_after_main_content'); ?>