Skip to content

Commit

Permalink
Merge pull request #1204 from greenpeace/planet-5388
Browse files Browse the repository at this point in the history
PLANET-5388 PLANET-5388 Fix related articles issue on Post
  • Loading branch information
sagarsdeshmukh authored Oct 21, 2020
2 parents 6823ce7 + f38c9eb commit 8d54605
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion single.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,21 @@
get_home_url()
);


// Build the shortcode for articles block.
if ( 'yes' === $post->include_articles ) {
$tag_id_array = [];
foreach ( $post->tags() as $post_tag ) {
$tag_id_array[] = $post_tag->id;
}
$category_id_array = [];
foreach ( $post->terms( 'category' ) as $category ) {
$category_id_array[] = $category->id;
}

$block_attributes = [
'exclude_post_id' => $post->ID,
'tags' => $tag_id_array,
'post_categories' => $category_id_array,
];

$post->articles = '<!-- wp:planet4-blocks/articles ' . wp_json_encode( $block_attributes, JSON_UNESCAPED_SLASHES ) . ' /-->';
Expand Down

0 comments on commit 8d54605

Please sign in to comment.