Skip to content
Merged
18 changes: 9 additions & 9 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 17 additions & 0 deletions inc/Core.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ private function run_hooks() {
add_action( 'after_setup_theme', array( $this, 'setup' ) );
add_action( 'wp_enqueue_scripts', array( $this, 'enqueue' ) );
add_action( 'enqueue_block_editor_assets', array( $this, 'add_editor_styles' ) );
add_action( 'pre_get_posts', array( $this, 'pre_get_posts' ) );
}

/**
Expand Down Expand Up @@ -107,4 +108,20 @@ public function enqueue() {
public function add_editor_styles() {
Assets_Manager::enqueue_style( Assets_Manager::ASSETS_SLUGS['editor-css'], 'editor' );
}

/**
* Modify the main query before it is executed.
*
* @param \WP_Query $query The WP_Query instance.
*/
public function pre_get_posts( \WP_Query $query ) {
// Only modify frontend main query.
if ( is_admin() || ! $query->is_main_query() || $query->is_feed() ) {
return;
}

if ( $query->is_archive() ) {
$query->set( 'posts_per_page', 4 );
}
}
}
2 changes: 1 addition & 1 deletion templates/archive.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

<!-- wp:group {"align":"full","style":{"spacing":{"padding":{"top":"64px","bottom":"64px"}}},"layout":{"inherit":true,"type":"constrained"},"otterConditions":[]} -->
<div class="wp-block-group alignfull" style="padding-top:64px;padding-bottom:64px">
<!-- wp:query {"queryId":4,"query":{"perPage":"4","pages":0,"offset":0,"postType":"post","order":"desc","orderBy":"date","author":"","search":"","exclude":[],"sticky":"","inherit":false},"displayLayout":{"type":"list","columns":2},"layout":{"inherit":true}} -->
<!-- wp:query {"queryId":4,"query":{"perPage":"4","pages":0,"offset":0,"postType":"post","order":"desc","orderBy":"date","author":"","search":"","exclude":[],"sticky":"","inherit":true},"displayLayout":{"type":"list","columns":2},"layout":{"inherit":true}} -->
<div class="wp-block-query">
<!-- wp:post-template -->
<!-- wp:group {"style":{"spacing":{"padding":{"top":"var:preset|spacing|60","bottom":"var:preset|spacing|60"}}},"backgroundColor":"ti-bg-alt","layout":{"inherit":true,"type":"constrained"},"otterConditions":[]} -->
Expand Down
Loading