Skip to content

Commit 744cf8b

Browse files
committedJan 14, 2022
Twelve posts per page
1 parent ecd5b17 commit 744cf8b

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed
 

‎inc/least.php

+17-3
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@ private function __construct() {
1919
$this->block_hooks();
2020
add_action( 'after_setup_theme', array( $this, 'support' ) );
2121
add_action( 'wp_enqueue_scripts', array( $this, 'enqueue' ) );
22-
// Changing excerpt more
22+
add_filter( 'pre_get_posts', array( $this, 'pre_get_posts' ) );
23+
24+
// Excerpt tweaks
2325
add_filter( 'excerpt_more', array( $this, 'excerpt_more' ) );
2426
add_filter( 'excerpt_length', array( $this, 'excerpt_length' ) );
2527
}
@@ -30,6 +32,7 @@ private function __construct() {
3032
*/
3133
private function block_hooks() {
3234
$blk = Least_Blocks::instance();
35+
$blk->register_patterns();
3336
add_filter( 'default_wp_template_part_areas', array( $blk, 'template_part_areas' ) );
3437
add_action( 'wp_head', array( $blk, 'before_maybe_inline_styles' ), 0 );
3538
}
@@ -68,12 +71,23 @@ public function enqueue() {
6871
wp_enqueue_style( 'least-style', get_template_directory_uri() . '/style.css', array(), wp_get_theme()->get( 'Version' ) );
6972
}
7073

74+
/**
75+
* @param WP_Query $query
76+
*/
77+
public function pre_get_posts( $query ) {
78+
if ( $query->is_main_query() ) {
79+
$post_archive = $query->is_archive() || $query->is_home() || $query->is_search();
80+
if ( $post_archive ) {
81+
$query->set( 'posts_per_page', 12 );
82+
}
83+
}
84+
}
85+
7186
/**
7287
* Adds read more link
73-
* @param int $count
7488
* @return string
7589
*/
76-
public function excerpt_length( $count ) {
90+
public function excerpt_length() {
7791
return 25;
7892
}
7993

0 commit comments

Comments
 (0)
Please sign in to comment.