Skip to content

Commit

Permalink
Merge pull request #686 from helsingborg-stad/fix/post-module-max-amo…
Browse files Browse the repository at this point in the history
…unt-of-posts

fix: post module maximum amount of posts to get
  • Loading branch information
NiclasNorin authored Nov 1, 2024
2 parents dfec9ae + cf7a195 commit 4777b86
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
4 changes: 2 additions & 2 deletions source/php/AcfFields/json/mod-posts-source.json
Original file line number Diff line number Diff line change
Expand Up @@ -164,15 +164,15 @@
"name": "posts_count",
"aria-label": "",
"type": "number",
"instructions": "Set to -1 to show all",
"instructions": "Amount of posts to show (Maximum of 100)",
"required": 1,
"conditional_logic": 0,
"wrapper": {
"width": "",
"class": "",
"id": ""
},
"default_value": -1,
"default_value": 10,
"min": "",
"max": "",
"step": "",
Expand Down
4 changes: 2 additions & 2 deletions source/php/AcfFields/php/mod-posts-source.php
Original file line number Diff line number Diff line change
Expand Up @@ -176,15 +176,15 @@
'name' => 'posts_count',
'aria-label' => '',
'type' => 'number',
'instructions' => __('Set to -1 to show all', 'modularity'),
'instructions' => __('Amount of posts to show (Maximum of 100)', 'modularity'),
'required' => 1,
'conditional_logic' => 0,
'wrapper' => array(
'width' => '',
'class' => '',
'id' => '',
),
'default_value' => -1,
'default_value' => 10,
'min' => '',
'max' => '',
'step' => '',
Expand Down
4 changes: 3 additions & 1 deletion source/php/Module/Posts/Helper/GetPosts.php
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,9 @@ private function getPostArgs(array $fields, int $page)

// Number of posts
if (isset($fields['posts_count']) && is_numeric($fields['posts_count'])) {
$getPostsArgs['posts_per_page'] = $fields['posts_count'];
$postsPerPage = ($fields['posts_count'] == -1 || $fields['posts_count'] > 100) ? 100 : $fields['posts_count'];

$getPostsArgs['posts_per_page'] = $postsPerPage;
}

// Apply pagination
Expand Down

0 comments on commit 4777b86

Please sign in to comment.