Then, select “PHP Snippet”
Creating a code snippet to automatically add Jump to Recipe buttons
In the code preview pane, insert the following lines of code:
The first part of the code, the function has_recipe_anchor, checks if there is a head tag (H1 to H6) in the blog post with an anchor set to “recipe”. The function preg_matchsearches the text for this specific pattern.
The second part, the function add_jump_to_recipe_button, is responsible for adding the actual taiwan telemarketing data button to the public.
If the function has_recipe_anchorfrom the previous step found a head with the recipe anchor, it creates the HTML code for the skip button. Then, it inserts this code just before the blog post content.
The last line of code, add_filter('the_content', 'add_jump_to_recipe_button');, essentially tells WordPress to run the function add_jump_to_recipe_buttonwhenever it retrieves the contents of a blog post.
This way, the code can automatically check the recipe header and add the button if necessary.
That said, you will need to add a #recipe anchor to the recipes section of your blog post. Don't worry, we'll show you how to do that later.
Now, scroll down to the “Insertion” section and make sure the “Automatic Insertion” method is selected. As for the location, you can choose “Frontend Only”, so that the code will only run on the front end of your WordPress website .
from the Code Type drop-down menu
-
- Posts: 260
- Joined: Sat Dec 21, 2024 5:40 am