Skip to content

Commit

Permalink
Added guard for page types
Browse files Browse the repository at this point in the history
  • Loading branch information
sathielemann committed Dec 3, 2019
1 parent 0d51726 commit bfb7f5b
Showing 1 changed file with 20 additions and 18 deletions.
38 changes: 20 additions & 18 deletions wp-category-permalink-gutenberg.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,26 +67,28 @@ CanonicalCategory = compose(
withSelect(function (select, props) {
var categoryarray = [];

for (var i = 0; i < props.postCategories.length; i++) {
var categorieId = props.postCategories[i];
var category = select('core').getEntityRecord('taxonomy', 'category', categorieId);

if (category) {
categoryarray.push({
label: category.name,
value: category.id
});
} else {
categoryarray.push({
label: categorieId + ' - Name is loading',
value: categorieId
});
if (props.postCategories) {
for (var i = 0; i < props.postCategories.length; i++) {
var categorieId = props.postCategories[i];
var category = select('core').getEntityRecord('taxonomy', 'category', categorieId);

if (category) {
categoryarray.push({
label: category.name,
value: category.id
});
} else {
categoryarray.push({
label: categorieId + ' - Name is loading',
value: categorieId
});
}
}

return {
categoryarray: categoryarray
};
}

return {
categoryarray: categoryarray
};
}),
withDispatch(function (dispatch) {
return {
Expand Down

0 comments on commit bfb7f5b

Please sign in to comment.