2 replaced http://wordpress.stackexchange.com/ with https://wordpress.stackexchange.com/
source | link

My category template shows 5 (full content) posts per page and I want to add a list of ALL the posts during the past week for that category to the top of the page as a quick overview. So the first post in the list will be same as first full-content post below the list, etc. except the overview list can have more than 5 posts.

I found this similar answerthis similar answer but it would only show 5 items at a time too, since that is my default posts per page setting.

I also tried using this code, but it shows posts from all categories. I only want to include the current category.

<?php

$args = array(
    'post_type'      => 'post',
    'post_status'    => 'publish',
    'orderby'        => 'date',
    'order'          => 'DESC',
    'date_query'     => array(
                            array(
                            'after' => '1 week ago'
                            )
                        )
);
$my_query = new WP_Query( $args );

if ( $my_query->have_posts() ) {

    echo '<ul>';

    while ( $my_query->have_posts() ) {
        $my_query->the_post();

        echo '<li><a href="' . get_permalink( $post -> ID ) . '">' . get_the_title() . '</a></li>';

    }

    echo '</ul>';

}
wp_reset_postdata();

?>

My category template shows 5 (full content) posts per page and I want to add a list of ALL the posts during the past week for that category to the top of the page as a quick overview. So the first post in the list will be same as first full-content post below the list, etc. except the overview list can have more than 5 posts.

I found this similar answer but it would only show 5 items at a time too, since that is my default posts per page setting.

I also tried using this code, but it shows posts from all categories. I only want to include the current category.

<?php

$args = array(
    'post_type'      => 'post',
    'post_status'    => 'publish',
    'orderby'        => 'date',
    'order'          => 'DESC',
    'date_query'     => array(
                            array(
                            'after' => '1 week ago'
                            )
                        )
);
$my_query = new WP_Query( $args );

if ( $my_query->have_posts() ) {

    echo '<ul>';

    while ( $my_query->have_posts() ) {
        $my_query->the_post();

        echo '<li><a href="' . get_permalink( $post -> ID ) . '">' . get_the_title() . '</a></li>';

    }

    echo '</ul>';

}
wp_reset_postdata();

?>

My category template shows 5 (full content) posts per page and I want to add a list of ALL the posts during the past week for that category to the top of the page as a quick overview. So the first post in the list will be same as first full-content post below the list, etc. except the overview list can have more than 5 posts.

I found this similar answer but it would only show 5 items at a time too, since that is my default posts per page setting.

I also tried using this code, but it shows posts from all categories. I only want to include the current category.

<?php

$args = array(
    'post_type'      => 'post',
    'post_status'    => 'publish',
    'orderby'        => 'date',
    'order'          => 'DESC',
    'date_query'     => array(
                            array(
                            'after' => '1 week ago'
                            )
                        )
);
$my_query = new WP_Query( $args );

if ( $my_query->have_posts() ) {

    echo '<ul>';

    while ( $my_query->have_posts() ) {
        $my_query->the_post();

        echo '<li><a href="' . get_permalink( $post -> ID ) . '">' . get_the_title() . '</a></li>';

    }

    echo '</ul>';

}
wp_reset_postdata();

?>
1
source | link

List ALL posts within last week from current category on category page

My category template shows 5 (full content) posts per page and I want to add a list of ALL the posts during the past week for that category to the top of the page as a quick overview. So the first post in the list will be same as first full-content post below the list, etc. except the overview list can have more than 5 posts.

I found this similar answer but it would only show 5 items at a time too, since that is my default posts per page setting.

I also tried using this code, but it shows posts from all categories. I only want to include the current category.

<?php

$args = array(
    'post_type'      => 'post',
    'post_status'    => 'publish',
    'orderby'        => 'date',
    'order'          => 'DESC',
    'date_query'     => array(
                            array(
                            'after' => '1 week ago'
                            )
                        )
);
$my_query = new WP_Query( $args );

if ( $my_query->have_posts() ) {

    echo '<ul>';

    while ( $my_query->have_posts() ) {
        $my_query->the_post();

        echo '<li><a href="' . get_permalink( $post -> ID ) . '">' . get_the_title() . '</a></li>';

    }

    echo '</ul>';

}
wp_reset_postdata();

?>