Hide filters and togglers when only one post is initially loaded

This commit is contained in:
Robbert de Kuiper 2017-03-31 14:19:02 +02:00
parent a995fbeb6b
commit 2e5eed917f
2 changed files with 11 additions and 6 deletions

View File

@ -38,6 +38,7 @@
width: 50%;
float: left;
overflow: hidden;
min-height: 1px; /* Show empty filterlist when there is only one post to keep the view intact. */
}
.ajax-posts__posts {

View File

@ -1,13 +1,17 @@
<section data-post-type="<?= $attributes['post_type']; ?>" data-quantity="<?= $attributes['posts_per_page']; ?>" class="js-container-async ajax-posts">
<div class="ajax-posts__status" style="display:none;"></div>
<button class="js-toggle-filters ajax-posts__toggle-filter">
<span class="ajax-posts__filter-recipes-text">+ <?php printf( __('Filter %s', 'ajax-filter-posts'), $plural_post_name); ?></span>
<span class="ajax-posts__show-recipes-text">+ <?php printf( __('Show %s', 'ajax-filter-posts'), $plural_post_name); ?></span>
<span class="ajax-posts__hide-filters-text">- <?= __('Hide filters', 'ajax-filter-posts'); ?></span>
</button>
<?php if ( $query->have_posts() && $query->post_count > 1) : ?>
<button class="js-toggle-filters ajax-posts__toggle-filter">
<span class="ajax-posts__filter-recipes-text">+ <?php printf( __('Filter %s', 'ajax-filter-posts'), $plural_post_name); ?></span>
<span class="ajax-posts__show-recipes-text">+ <?php printf( __('Show %s', 'ajax-filter-posts'), $plural_post_name); ?></span>
<span class="ajax-posts__hide-filters-text">- <?= __('Hide filters', 'ajax-filter-posts'); ?></span>
</button>
<?php endif; ?>
<div class="ajax-posts__view">
<aside class="ajax-posts__filters">
<?php include(plugin_dir_path( __FILE__ ) . 'partials/filters.php' ); ?>
<?php if ( $query->have_posts() && $query->post_count > 1) : ?>
<?php include(plugin_dir_path( __FILE__ ) . 'partials/filters.php' ); ?>
<?php endif; ?>
</aside>
<div class="ajax-posts__posts">
<?php include(plugin_dir_path( __FILE__ ) . 'partials/loop.php' ); ?>