-1

I want to create a shortcode for following HTML content:

i want print different alert or messages using that

HTML code

<div class="notify"><span class="symbol icon-fact"></span> <strong>THIS IS TITLE !</strong>
MY HTML CONTENT HERE
</div>

Desirable print on text editor

[st_highlight mstyle="notify"  ICON="symbol icon-star" title="THIS IS TITLE" ]
MY HTML CONTENT HERE
[/st_highlight]

enter image description here

after using shortcodes i able to change manually on text editor div ,icon and title using css class for example when i put like below through shortcodes

[st_highlight mstyle="notify_red"  ICON="symbol icon-question_marks" title="" ]
    MY HTML CONTENT HERE
    [/st_highlight]

enter image description here

finally i able to generate different style with different css class , i try to use below html directory on wordpress text editor but some tags are not supported that's why i want to create shortcode based style editable alert or messages codes

<div class="notify"><span class="symbol icon-star"></span> <strong>THIS IS TITLE</strong>

<ul>BELOW ARE ONLY SAMPLE HTML CONTENT 
<li>WHATEVER CONTENT</li>
<li>WHATEVER CONTENT</li>
<li>WHATEVER CONTENT</li>
<li>WHATEVER CONTENT</li>
</ul>
</div>
  • You’ve rejected an answer that is correct because they did not read your mind to understand what you actually want to do. Please update your question with the full information. – Jacob Peattie Jul 26 '18 at 11:30
  • yes ! ,now i try to explain with more information – shanky Jul 26 '18 at 12:18
1

Please use below code

 function html_show($atts) {

   $makearr =  explode(",",$atts['content']);
   if(isset($makearr) && !empty($makearr)) { 
   foreach($makearr as $arrval){
    $stringli .= '<li>'. $arrval.'</li>';
   }
   } else {
   $stringli = '';
   }  
    $htmlcode = '<div class="notify"><span class="symbol icon-fact"></span> <strong>A kind of a notice box !</strong><ul>'.$stringli.'</ul>
</div>';
    return $htmlcode;
}
add_shortcode( 'htmltag', 'html_show' );


  /*******Using method*******/
echo do_shortcode('[htmltag content="message1,message2,message3,message4"]'); 

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.