[Support request] Query loop wp recipe maker

Home Forums Support [Support request] Query loop wp recipe maker

Home Forums Support Query loop wp recipe maker

Viewing 5 posts - 16 through 20 (of 20 total)
  • Author
    Posts
  • #2363809
    Kees

    Oke, thanks, i will ask that.

    #2364606
    Fernando
    Customer Support

    You’re welcome Kees!

    #2364914
    Kees

    FYI, we made it work with https://help.bootstrapped.ventures/article/110-access-recipes-in-a-post-via-code

    Now the code looks like this:

    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 );

    #2364916
    Kees

    If the code can be optimized, let me know

    #2364928
    Fernando
    Customer Support

    I see. It does need an ID generated by the plugin. I thought it was using the Post ID which was why the code wasn’t working in the first place.

    It looks good. Thank you for sharing!

Viewing 5 posts - 16 through 20 (of 20 total)
  • You must be logged in to reply to this topic.