php – Strange layout behaviour – code render on frontent 3 times instead once

Question

I created PHP snippet which should render related posts at the end of quiz I am developing. Strange thing is that code renders on frontnend three times (creates three boxes) instead just once. Repeating block screenshot below:

Screenshot

Code I used (for functions.php) is as follows:

add_filter('render_block_buzzeditor/trivia-result', 'add_related_post_to_results', 10, 2);
add_filter('render_block_buzzeditor/personality-result', 'add_related_post_to_results', 10, 2);

function add_related_post_to_results($block_content, $block)
{
    $settings = array(
            'title'               => 'So you are a category wiz?! Try some more trending category quizzes to prove it...',
            'taxonomy_relation'   => 'OR',
            'order_by'            =>'popular_week',
            'count'               => 3,
            'pagination'          => 'next_prev' ,
            'header_style'        => 'style-1',
            'block_width'         => 3,
            'block_extra_classes' => 'quiz-related-posts',
        );

    // block name
    $block = ak_get_shortcode( 'newsy_list_2' );

    $related_content = $block->render_shortcode( $settings, null );

    return $block_content.$related_content;
}

Any idea or advice? Thank you all—

0
ZeusDev 2 months 2022-10-11T10:38:05-05:00 0 Answers 0 views 0

Leave an answer

Browse
Browse