Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
78 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 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...