0

I have custom post type called "forms" and has a sub-menu page which has form, to add a name

add_action('admin_menu', 'form_builder_add');

function form_builder_add() {

  //create new top-level menu
  add_submenu_page('edit.php?post_type=forms', 'Add name', 'Add name', 'manage_options', 'form-dashboards', 'add_names');

}

function add_names() {
    echo 
    '
        <form method="post" action="">
            <input type="text" name="name" id="name" />
            <input type="submit" value="submit" />
        </form>
    ';
}

and I have shortcode and foocode where I want to spit out the values from the form.

add_shortcode( 'foocode', 'prefix_foocode' );

function prefix_foocode() {

    return 'This is  '. $_POST['name'] . ' testing';
}

So when I call the shortcode from the post it should have the value of name from the form.

[foocode]

This is example name testing

  • Do you want to save the name through form in admin page and display it through shortcode on front-end? – Qaisar Feroz Feb 23 at 17:05

Your Answer

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

Browse other questions tagged or ask your own question.