Reputation: 545
i have to write a WordPress plugin which should provide a new subpage with some kind of contact form. The plugins I've made yet only changed something in the existing files using the hooks and I don't know how to create a new subpage which is embedded into the main Wordpress layout. The plugin should also add a link to this subpage into the main navigation of the blog.
Upvotes: 0
Views: 1185
Reputation: 1005
I know it's pretty annoying but... You can't make a page on the actual blog in a plugin you make. you can however, make a shortcode like [contact-form]
that will output the form. The user just needs to put that shortcode on a page and it will put the form there. Some reference for shortcodes can be found here: ShortCode API. But the main syntax for creating a shortcode is this:
//[foobar]
function foobar_func( $atts ){
return "foo and bar";
}
add_shortcode( 'foobar', 'foobar_func' );
Just put the form code inside the function and change the name. You don't need attributes though. For your case you would just need to do something like this:
function contact_form(){
//Code that process form
//Actual code that outputs the form
}
And there you go! Thanks!
Ethan Brouwer
Upvotes: 1