Wil je op de homepage een query loop maken met WP recipe maker data? Voeg dan deze code toe aan de functions.php


add_filter( 'render_block', function( $block_content, $block ) {
    if ( !is_admin() && ! empty( $block['attrs']['className'] ) && strpos( $block['attrs']['className'], 'insert-my-shortcode' ) !== false ) {

        $recipes = WPRM_Recipe_Manager::get_recipe_ids_from_post();


        // Access the first recipe, if there is one.
        if ( isset( $recipes[0] ) ) {
            $recipe_id = $recipes[0];
            $recipe = WPRM_Recipe_Manager::get_recipe( $recipe_id );

            // Output the recipe name.
           // echo $recipe->name();
        }
    
    $block_content =  do_shortcode('[wprm-recipe-time type="total" id="'.$recipe_id.'" ]');
    
    }

    return $block_content;
}, 10, 2 );

Kies vervolgens in Gutenberg een koptekst blok. Zet daarop de class: insert-my-shortcode