EasyRecipe Shortcode

Below, you’ll find a detailed guide on how to add the EasyRecipe Shortcode to your WordPress website, including its parameters, examples, and PHP function code. Additionally, we’ll assist you with common issues that might cause the EasyRecipe Plugin shortcode not to show or not to work correctly.

Before starting, here is an overview of the EasyRecipe Plugin and the shortcodes it provides:

Plugin Icon
EasyRecipe

"EasyRecipe is a user-friendly WordPress plugin designed to simplify the process of adding, sharing, and managing recipes on your website or food blog. Provides a seamless user experience."

★★☆✩✩ (63) Active Installs: 2000+ Tested with: 4.9.24 PHP Version: false
Included Shortcodes:
  • [easyrecipe]

EasyRecipe [easyrecipe] Shortcode

The EasyRecipe shortcode is a tool that allows you to insert a recipe into a WordPress post. This shortcode uses the ‘replaceRecipeShortcode’ function, which takes an attribute ‘n’ and returns the corresponding recipe from an array of recipes. This allows for easy and dynamic insertion of recipes into your content.

Shortcode: [easyrecipe]

Parameters

Here is a list of all possible easyrecipe shortcode parameters and attributes:

  • n – Specifies the index of the recipe in the recipesHTML array

Examples and Usage

Basic example – A simple usage of the ‘easyrecipe’ shortcode to display a recipe by referencing its ID.

[easyrecipe n=1 /]

Advanced examples

Using the ‘easyrecipe’ shortcode to display a recipe by referencing its ID. If the recipe with the given ID is not found, it will not display anything.

[easyrecipe n=3 /]

Here is another advanced usage of the ‘easyrecipe’ shortcode. In this example, we are trying to display a recipe with an ID that doesn’t exist. This will not display anything, as there is no recipe with such an ID.

[easyrecipe n=999 /]

Please note that the ‘n’ parameter in the shortcode is used to specify the ID of the recipe. You need to replace it with the actual ID of the recipe that you want to display.

PHP Function Code

In case you have difficulties debugging what causing issues with [easyrecipe] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode('easyrecipe', array($this, 'replaceRecipeShortcode'));

Shortcode PHP function:

function replaceRecipeShortcode($attributes) {
        return do_shortcode($this->recipesHTML[$attributes['n']]);
    }

Code file location:

easyrecipe/easyrecipe/lib/EasyRecipe.php

Conclusion

Now that you’ve learned how to embed the EasyRecipe Plugin shortcode, understood the parameters, and seen code examples, it’s easy to use and debug any issue that might cause it to ‘not work’. If you still have difficulties with it, don’t hesitate to leave a comment below.

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *