Skip to content

Commit

Permalink
Add poststoshow attribute with a default value 5
Browse files Browse the repository at this point in the history
  • Loading branch information
lamosty committed May 24, 2017
1 parent 6321900 commit e88a06f
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion blocks/library/latest-posts/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,18 @@ registerBlock( 'core/latest-posts', {
latestPosts: []
};

getLatestPosts().then( latestPosts => this.setState( { latestPosts } ) );
let { poststoshow } = this.props.attributes;

if ( ! poststoshow ) {
poststoshow = 5;

this.props.setAttributes( {
poststoshow
} );
}

getLatestPosts( poststoshow )
.then( latestPosts => this.setState( { latestPosts } ) );
}

renderPostsLoading() {
Expand Down

0 comments on commit e88a06f

Please sign in to comment.