I am using Cooked (cooked.boxydemos.com) plugin to show recipes. I have created a new template to show all recipes + filter, so copied PHP from Cooked plugin in order to customise is (design/template changes, no heavy coding). All recipes are shown fine and filtering is working as well.
However, when I click on "Page 2 or 3,4..." I am not seeing any results, just a message "No content in this loop". Any ideas?
Here is my all-recipes.php
<?php
/*
Template Name: All Recipes
*/
?>
<?php get_header(); ?>
<?php global $cooked_query; $is_page = is_page(); $is_post = is_single(); $no_results = false; ?>
<div class="container-fluid image-header-title">
<div class="row">
<div class="col-sm-12">
<?php the_title( '<h1 class="text-center">', '</h1>' ); ?>
<?php the_content(); ?>
</div>
</div>
</div>
<div class="container-fluid recipe-filter-section" id="cooked-plugin-page">
<!-- FILTERS -->
<div class="container">
<div class="row">
<div class="col-sm-12">
<?php if($is_page || $is_post) : ?>
<div class="search-section">
<?php cp_recipe_search_section(); ?>
</div><!-- /.search-section -->
<?php
$args = cp_search_args();
if ($args):
$cooked_query = new WP_Query( $args );
else :
$no_results = true;
endif;
elseif (is_archive()):
global $archive_args;
if ($archive_args):
$cooked_query = new WP_Query( $archive_args );
else :
$no_results = true;
endif;
endif; ?>
</div>
</div>
</div>
</div> <!--/ end of CONTAINER-FLUID -->
<!-- ALL RECIPES -->
<div class="container-fluid">
<div class="container all-recipes" id="cooked-plugin-page">
<div class="row">
<div class="col-sm-12 col-md-9">
<div class="cooked-result-section cooked-masonry-layout cookedClearFix">
<div class="cooked-loading-content">
<?php if ( isset($cooked_query) && $cooked_query->have_posts() && !$no_results) :
$recipe_info = cp_recipe_info_settings();
echo '<div class="grid-sizer"></div>';
while ( $cooked_query->have_posts() ):
$cooked_query->the_post(); global $post;
$entry_id = $post->ID;
$entry_link = get_permalink($entry_id);
$entry_image = get_post_meta($entry_id, '_thumbnail_id', true);
$entry_title = get_the_title($entry_id);
$entry_rating = cp_recipe_rating($entry_id);
$entry_description = get_post_meta($entry_id, '_cp_recipe_short_description', true);
$entry_excerpt = get_post_meta($entry_id, '_cp_recipe_excerpt', true);
$prep_time = get_post_meta($entry_id, '_cp_recipe_prep_time', true);
$cook_time = get_post_meta($entry_id, '_cp_recipe_cook_time', true);
$total_time = $prep_time + $cook_time;
$entry_yields = get_post_meta($entry_id, '_cp_recipe_yields', true); ?>
<div class="cooked-result-box item">
<div class="cp-box">
<div class="cp-box-img">
<?php if(!empty($entry_image)) {
echo '<a href="'.$entry_link.'">'.wp_get_attachment_image($entry_image, 'cp_298_192').'</a>';
} else {
echo '<a href="'.$entry_link.'"><img src="'.CP_PLUGIN_URL.'/css/images/default_298_192.png"></a>';
}
?>
</div><!-- /.cp-box-img -->
<div class="cp-box-entry">
<h3><a href="<?php echo $entry_link; ?>"><?php echo $entry_title; ?></a><?php
?></h3>
<?php if (in_array('rating', $recipe_info)) : ?><div class="rating rate-<?php echo $entry_rating; ?>"></div><!-- /.rating --><?php endif; ?>
<?php if (in_array('author', $recipe_info)) :
echo '<p class="terms-list">';
$author_id = get_the_author_meta('ID');
$nickname = get_the_author_meta('nickname');
$username = get_the_author_meta('user_login');
if (!$nickname) { $nickname = $username; }
$username = cp_create_slug($username);
$avatar_image = false;
if (in_array('author_avatar', $recipe_info)) :
$avatar_image = cp_avatar($author_id,50);
endif;
$profile_page_link = (get_option('cp_profile_page') ? get_permalink(get_option('cp_profile_page')) : false);
$profile_page_link = rtrim($profile_page_link, '/');
if ($profile_page_link):
echo '<span>'.($avatar_image ? $avatar_image : '<i class="fa fa-user"></i> ') . __('By','cooked') . ' <a href="' . $profile_page_link . '/' . $username . '/">' . $nickname.'</a></span>';
endif;
echo '</p>';
endif; ?>
</div><!-- /.cp-box-entry -->
<?php if ($entry_yields || $total_time): if (in_array('timing', $recipe_info) || in_array('yields', $recipe_info)) : ?>
<div class="cp-box-footer">
<div class="timing">
<ul>
<?php if (in_array('timing', $recipe_info) && $total_time) : ?>
<?php if ($prep_time): ?><li><strong><?php _e('Prep','cooked'); ?>:</strong> <?php echo cp_format_time($prep_time); ?></li><?php endif; ?>
<?php if ($cook_time): ?><li><strong><?php _e('Cook','cooked'); ?>:</strong> <?php echo cp_format_time($cook_time); ?></li><?php endif; ?>
<?php endif; ?>
</ul>
</div><!-- /.timing -->
</div><!-- /.cp-box-footer -->
<?php endif; endif; ?>
</div><!-- /.cp-box -->
</div><!-- /.cooked-result-box -->
<?php endwhile;
else : ?>
<div class="cooked-result-box item">
<p><?php _e('No recipes found.','cooked'); ?></p>
</div><!-- /.cooked-result-box -->
<?php endif; ?>
</div><!-- /.cooked-loading-content -->
</div><!-- /.cooked-result-section -->
<?php cp_pagination();
if($is_page) {
wp_reset_postdata();
} ?>
</div>
<div class="col-sm-12 col-md-3 advert-space">
<?php if ( is_active_sidebar( 'ads_recipes_page' ) ) : ?>
<div id="primary-sidebar" class="primary-sidebar widget-area" role="complementary">
<?php dynamic_sidebar( 'ads_recipes_page' ); ?>
</div>
<?php endif; ?>
</div>
</div>
</div>
</div>
<?php get_footer(); ?>
And when I click on next page it looks like it shows what I have in my index.php, which is below:
<?php get_header(); ?>
<div id="main-container" class="container">
<div class="row">
<div class="col-sm-12">
<?php the_title('<h1>','</h1>'); ?>
</div>
</div>
<div class="row">
<div class="col-md-12 padding-bottom">
<?php if(have_posts()) : ?>
<?php while(have_posts()) : the_post(); ?>
<div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<?php the_content(); ?>
</div>
<?php
if (is_singular()) {
// support for pages split by nextpage quicktag
wp_link_pages();
// tags anyone?
the_tags();
}
?>
<?php endwhile; ?>
<?php else : ?>
<div class="alert alert-info">
<strong>No content in this loop</strong>
</div>
<?php endif; ?>
</div>
</div>
</div>
<?php get_footer(); ?>
Any ideas why this happening and how to fix it, please?
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire