Answer the question
In order to leave comments, you need to log in
How to set logic with a selection of posts "for the last month" on a page with massonri staging and infinite scroll?
Some kind of ass I make a selection in index.php as usual, but it doesn’t work
Into a clean section of code as it is:
<?php if ( have_posts() ) { ?>
<div class="boxcontainer">
<?php while ( have_posts() ) { the_post(); ?>
<?php get_template_part('pinbox', get_post_format()); ?>
<?php } ?>
</div>
<?php
ob_start();
posts_nav_link(' ', __('Previous Page', 'pinthis'), __('Next Page', 'pinthis'));
$pinthis_posts_nav_link = ob_get_clean();
?>
<?php if(strlen($pinthis_posts_nav_link) > 0) { ?>
<div class="container">
<div class="posts-navigation clearfix <?php if ($pinthis_infinite_scroll == 1) { ?>hide<?php } ?>"><?php echo $pinthis_posts_nav_link; ?></div>
</div>
<?php } ?>
<?php } else { ?>
/*====================================*\
SET POST PER PAGE
\*====================================*/
function pinthis_posts_per_page($query) {
$user_posts_per_page = get_option('posts_per_page');
if ($user_posts_per_page < 10) {
update_option('posts_per_page', 10);
}
}
add_action('pre_get_posts', 'pinthis_posts_per_page');
/*====================================*\
<?php
// WP_Query arguments
$last_month_args = array(
'post_type' => 'post',
'post_status' => 'publish',
'orderby' => 'date',
'order' => 'DESC',
// Using the date_query to filter posts from last week
'date_query' => array(
array(
'after' => '1 week ago'
)
)
);
// The Query
$last_month_posts = new WP_Query( $last_month_args );
// The Loop
if ( $last_month_posts->have_posts() ) {
while ( $last_month_posts->have_posts() ) {
$last_month_posts->the_post();
// контент поста
the_title();
the_post_thumbnail();
}
} else {
// Если постов нет
}
// Restore original Post Data
wp_reset_postdata();
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question