Skip to content

Commit

Permalink
[#39] setting number of post per page on auction index
Browse files Browse the repository at this point in the history
  • Loading branch information
nathan-schmidt-viget committed Dec 18, 2023
1 parent 8324d4f commit cf4452f
Showing 1 changed file with 24 additions and 3 deletions.
27 changes: 24 additions & 3 deletions client-mu-plugins/goodbids/src/classes/Auctions/Auctions.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ public function __construct() {
// Update Bid Product when Auction is updated.
$this->update_bid_product_on_auction_update();

// Set the auction archive page in the main navigation
$this->set_auction_archive_posts_per_page();

// Sets a default image
$this->set_default_feature_image();
}
Expand Down Expand Up @@ -459,7 +462,25 @@ function ( int $post_id ) {
}

/**
* Update the Bid Product when an Auction is updated.
* Set the Auction archive page to show nine posts per pagination
*
* @since 1.0.0
*
* @return void
*/
private function set_auction_archive_posts_per_page(): void {
add_action(
'pre_get_posts',
function ( $query ) {
if ( ! is_admin() && is_post_type_archive( 'gb-auction' ) ) {
$query->set( 'posts_per_page', 9 );
}
}
);
}

/**
* Set the default feature image for Auction
*
* @since 1.0.0
*
Expand All @@ -474,8 +495,8 @@ function ( string $html, int $auction_id ) {
}

if ( is_post_type_archive( 'gb-auction' ) ) {
$reward_id = goodbids()->auctions->get_reward_product_id( $auction_id );
$product = wc_get_product( $reward_id );
$reward_id = goodbids()->auctions->get_reward_product_id( $auction_id );
$product = wc_get_product( $reward_id );
$product_html = $product->get_image();
return sprintf(
$product_html,
Expand Down

0 comments on commit cf4452f

Please sign in to comment.