Reputation:
Hi i am having short code look like [mytable name="student"]
it having some columns. for example name,regsiter_number,address, etc..
how to display form in front end of wordpress?
for example
How to write code for this process in my plugin?
Now i am using following code in my plugin
<?php
//shortcode [mytable name="student"]
function mytable_shortcode($atts)
{
extract(shortcode_atts(array(
'name'=>''
), $atts));
return "{$name}";
}
?>
Help me.
Upvotes: 2
Views: 4053
Reputation: 719
Here is sample code for you.
function my_registration_form($params, $content = null) {
extract(shortcode_atts(array(
'type' => 'style1'
), $params));
ob_start();
?>
<form action="../home" method="get">
<ul>
<li>
<label>Name</label>
<input name="name" type="text" id="name">
</li>
<li>
<label>Register Number</label>
<input name="register_num" type="text" id="reg_num">
</li>
<li>
<label>Address</label>
<input name="address" type="text" id="address">
</li>
<li>
<input type="submit" value="Save">
</li>
</ul>
</form>
<?php return ob_get_clean();
}
add_shortcode('my_form','my_registration_form');
And use [my_form]
shortcode to display form.
Upvotes: 4