Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
76 views
in Technique[技术] by (71.8m points)

php - How to convert to enclosed shortcode

I want to create an shortcode to add ingredients to recipes on a wordpress website. I have the the function to create a shortcode, but I don't knw how to convert it to an enclosed shortcode that i will use many times on different pages.I want to add other ingredients each time:

function my_new_ingredients_shortcode() {
   return '<div class="recipe-modal-message no-print">
<div class="inner-modal">
<div class="modal-message-content">
<h3>Hooray!</h3>
You have all the ingredients, let us start cooking!

</div>
</div>
</div>
<h2 class="heading-title recipe-ingredients-heading">My New Ingredients</h2>
<ul class="recipe-checklist">
    <li class="checklist-item do-action"><label><span class="recipe-ing-text">ingredient 1</span>
</label></li>
    <li class="checklist-item do-action"><label><span class="recipe-ing-text">ingredient 2</span>
</label></li>
    <li class="checklist-item do-action"><label><span class="recipe-ing-text">ingredient 3</span></label></li>
    <li class="checklist-item do-action"><label><span class="recipe-ing-text">ingredient 4</span></label></li>
    
</ul>
</div>
<div class="recipe-modal-message no-print">
<div class="inner-modal">
<div class="modal-message-content">
<h3>Good job!</h3>
Enjoy your meal, hope you had fun with us!

</div>
</div>
</div>';
}
add_shortcode( 'mynewingredients', 'my_new_ingredients_shortcode' );

My knowlodges are limited so thank you in advance!

question from:https://stackoverflow.com/questions/65626332/how-to-convert-to-enclosed-shortcode

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...