Set number of posts via function instead of index
This commit is contained in:
parent
64f6ed823d
commit
6647435c11
2 changed files with 4 additions and 47 deletions
|
|
@ -23,7 +23,9 @@ add_filter('acf/fields/google_map/api', 'my_acf_google_map_api');
|
|||
// Only show posts of category Urlaub (id=2)
|
||||
function my_home_category( $query ) {
|
||||
if ( $query->is_home() && $query->is_main_query() ) {
|
||||
$query->set( 'cat', '2');
|
||||
$query->set( 'cat', '2');
|
||||
// set number of posts to 9
|
||||
$query->set( 'posts_per_page', '9');
|
||||
if ( !empty( $_GET['person'] ) ) {
|
||||
$query->set( 'meta_query', array(
|
||||
array(
|
||||
|
|
@ -82,4 +84,4 @@ function atravelblog_related_posts() {
|
|||
add_post_image_thumbs($urlaub, 'Urlaub:');
|
||||
wp_reset_query();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
45
index.php
45
index.php
|
|
@ -1,45 +0,0 @@
|
|||
<?php get_header(); ?>
|
||||
|
||||
<div class="content section-inner">
|
||||
<?php query_posts('posts_per_page=12'); ?>
|
||||
<?php if (have_posts()) : ?>
|
||||
|
||||
<?php
|
||||
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
|
||||
$total_post_count = wp_count_posts();
|
||||
$published_post_count = $total_post_count->publish;
|
||||
$total_pages = ceil( $published_post_count / $posts_per_page );
|
||||
|
||||
if ( "1" < $paged ) : ?>
|
||||
|
||||
<div class="page-title">
|
||||
|
||||
<h4><?php printf( __('Page %s of %s', 'hitchcock'), $paged, $wp_query->max_num_pages ); ?></h4>
|
||||
|
||||
</div> <!-- /page-title -->
|
||||
|
||||
<div class="clear"></div>
|
||||
|
||||
<?php endif; ?>
|
||||
|
||||
<div class="posts" id="posts">
|
||||
|
||||
<?php while (have_posts()) : the_post(); ?>
|
||||
|
||||
<?php get_template_part( 'content', get_post_format() ); ?>
|
||||
|
||||
<?php endwhile; ?>
|
||||
|
||||
<div class="clear"></div>
|
||||
|
||||
</div> <!-- /posts -->
|
||||
|
||||
<?php endif; ?>
|
||||
<?php wp_reset_query() ?>
|
||||
<div class="clear"></div>
|
||||
|
||||
<?php hitchcock_archive_navigation(); ?>
|
||||
|
||||
</div> <!-- /content -->
|
||||
|
||||
<?php get_footer(); ?>
|
||||
Loading…
Add table
Add a link
Reference in a new issue