24 days not 25.

parent 2bebb8c6
Pipeline #77 canceled with stage
......@@ -13,6 +13,7 @@
*/
define( 'CAC_ADVENT_DAY_TYPE', 'advent_day' );
define( 'CAC_ADVENT_NUM_DAYS', 24 );
define( 'CAC_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
add_action( 'plugins_loaded', function () {
......
......@@ -39,7 +39,7 @@ class Codeup_Advent_Calendar {
self::$template_loader = new Advent_Calendar_Template_Loader;
add_filter( 'template_include', [ $this, 'template_include' ] );
add_filter( 'body_class', [ $this, 'body_class' ], 10 );
add_action( 'pre_get_posts', [ $this, 'show_25_days' ] );
add_action( 'pre_get_posts', [ $this, 'show_all_days' ] );
if ( is_admin() ) {
add_action( 'pre_get_posts', [ $this, 'sort_by_day' ] );
......@@ -94,10 +94,10 @@ class Codeup_Advent_Calendar {
}
/**
* Create all 25 default pages. Setting the title and slug.
* Create all CAC_ADVENT_NUM_DAYS default pages. Setting the title and slug.
*/
public function create_default_pages() {
for ( $d = 25; $d > 0; --$d ) {
for ( $d = CAC_ADVENT_NUM_DAYS; $d > 0; --$d ) {
wp_insert_post(
[
'post_type' => CAC_ADVENT_DAY_TYPE,
......@@ -142,11 +142,11 @@ class Codeup_Advent_Calendar {
}
/**
* Show 25 days when displaying on the front end.
* Show CAC_ADVENT_NUM_DAYS days when displaying on the front end.
*
* @param WP_Query $wp_query The current query.
*/
public function show_25_days( WP_Query $wp_query ) {
public function show_all_days( WP_Query $wp_query ) {
if ( is_admin() ) {
return;
}
......@@ -156,7 +156,7 @@ class Codeup_Advent_Calendar {
$orderby = $wp_query->get( 'orderby' );
if ( empty( $orderby ) ) {
$wp_query->set( 'orderby', 'rand' );
$wp_query->set( 'posts_per_page', '25' );
$wp_query->set( 'posts_per_page', CAC_ADVENT_NUM_DAYS );
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment