C
C
Chokatillo2017-02-05 16:12:42
PHP
Chokatillo, 2017-02-05 16:12:42

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 { ?>

In function.php there is a code with the task of the number of records per page:
/*====================================*\
  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');

/*====================================*\

I didn’t find anything else according to the template. There
is no selection function.
There is an algorithm code that I need:
<?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();

BUT, I can't glue it all together. Either posts are impudently copied in 10 pieces, despite the settings, then the posts are simply not displayed
Guys, help me collect a sample from this by month
Well please! )
Thank you!

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question