[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 15 posts - 1 through 15 (of 20 total)
  • Author
    Posts
  • #2361649
    Kees

    Hi,

    We would like to build a queryloop with data from blog posts and WP recipemaker data.
    Wp recipemaker has shortcodes.

    How can we use the shortcodes in a recipe?

    https://help.bootstrapped.ventures/article/83-recipe-shortcodes

    #2361948
    Ying
    Staff
    Customer Support

    Hi Kees,

    Have you tried using a block element – content template, and adding shortcode block with the shortcode from the plugin to the block element?

    Let me know if that works.

    #2362274
    Kees

    Hi,

    But it is just a part of the homepage, not the full homepage. With a block element you replaces the content.
    Therefore we use the query loop.

    #2362281
    Fernando
    Customer Support

    Hi Kees,

    We’ll need to code it in. Shortcodes don’t work in the WordPress or GenerateBlocks Query Loop Block. It’s a WordPress issue.

    Can you provide the link to your site, and we’ll take a look at your Query loop? And, can you also point out where exactly in the loop would you like to add the Shortcode?

    You may use the Private Information field for this: https://docs.generatepress.com/article/using-the-premium-support-forum/#private-information

    #2362345
    Kees

    Hi,

    Nice. I made a fresh installation for you.
    See login in private information. See the wp recipe maker data: https://help.bootstrapped.ventures/article/83-recipe-shortcodes

    It is important the the data is shown. The styling is the part we can fix.

    #2362380
    Fernando
    Customer Support

    Ideally, for a structure like that, you’ll need to add the image to the Container Block, and then add the contents inside.

    Now, for the Shortcode, add a GB Headline Block as a placeholder. Enable dynamic data and set the Source to anything, like Title.

    Then add class insert-my-shortcode to the class list of the Headline Block.

    How to add custom class: https://wordpress.com/support/adding-additional-css-classes-to-blocks/

    Then, add this Snippet:

    add_filter('generateblocks_dynamic_content_output', function($content, $attributes, $block){
    	if ( ! empty( $attributes['className'] ) && strpos( $attributes['className'], 'insert-my-shortcode' ) !== false ) {
    		
    	$content = do_shortcode('[wprm-recipe]');
    	}
    	return $content;
    }, 10, 3);

    Replace the Shortcode with your shortcode. Not sure if [wprm-recipe] will grab the recipe of the current post. Do you need the ID for that?

    #2362468
    Kees

    Hi,

    We are almost there. It only shows the same time for al posts. I used [wprm-recipe-time type=”total”]. This is to show the total time. But i is for al the post the same. And i changed one recipe with another time.

    Is there a way to fix this?

    #2363403
    Fernando
    Customer Support

    Not sure how that Shortcode works. If you place that Shortcode in individual Posts, do the intended values show?

    #2363722
    Kees

    Hi,

    Yes, then the time is shown. See link in private.

    #2363749
    Fernando
    Customer Support

    I changed the code above: https://generatepress.com/forums/topic/query-loop-wp-recipe-maker/#post-2362380

    Can you use that instead? And remove class from the class list of the Headline Block.

    #2363756
    Kees

    Hi,

    No, it keeps showing the same time for all the posts. Weird. Do you have an other option?

    #2363761
    Kees

    .

    #2363764
    Fernando
    Customer Support

    Can you try this snippet instead?:

    add_filter( 'render_block', function( $block_content, $block ) {
        if ( !is_admin() && ! empty( $block['attrs']['className'] ) && strpos( $block['attrs']['className'], 'insert-my-shortcode' ) !== false ) {
    		
    		$block_content =  $block_content . do_shortcode('[wprm-recipe-time type="total"]');
    		
        }
    
        return $block_content;
    }, 10, 2 );
    #2363766
    Kees

    Hi,

    Nope, still not working. I feel sorry for you :p
    Any other options?

    #2363770
    Fernando
    Customer Support

    I see. I think it’s because of the Shortcode. I tested both PHP codes I provided on Shortcodes functioning to retrieve Post meta and it’s working as expected.

    I won’t know why it’s not working as I have no access to the Shortcode.

    It would be best to reach out to the support of that plugin for assistance at this point. Ask if it’s possible to add and make that shortcode work on a Query Loop Block through render_block filter.

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