php - How do i call shortcode value from dashboard editor? -



php - How do i call shortcode value from dashboard editor? -

i have used shortcode this:

<?php add_shortcode( 'myproduct', 'myproduct_func' ); function myproduct_func( $atts ) { extract( shortcode_atts( array( 'cols' => 'none', 'data' => 'none', ), $atts ) ); $cols = explode(',',$cols); $data = explode(',',$data); $total = count($cols); $output = ""; foreach($cols $col): $output .= "| {$col} "; endforeach; $output .= "<br>"; $counter = 1; foreach($data $datum): $output .= "| {$datum} "; if($counter%$total==0): $output .= "<br>"; endif; $counter++; endforeach; homecoming $output; } ?>

do display shortcode when write code :

echo do_shortcode('[myproduct cols="name,quantity,price" data="name1,5,2.00,name2,3,3.25"]');

in index.php display table on home page but:

same code [myproduct cols="name,quantity,price" data="name1,5,2.00,name2,3,3.25"] when write in home page dashboard editor, shows nil on home page. want value of cols , info dynamic should passed through dashboard.

are doing in visual or text editor? shortcodes work must on text editor in tinymce on right tabs.

also must include myproduct_func in functions.php it's available.

php wordpress shortcode

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -