theme development – How to access variables defined in a page, in another page
I have a form using get method, this form purpose is to get what type of post the user whant to create in the frontend. And depending on the type chosen, a (form using post method) is pushed out.
But I actually need the values passed in the variables that I used, to get the type chosen, to put it in the “`wp_inset_post()“` function…
I tried to put them in another php file, and require them using “`get_template_part()“` but their values are null.
Here’s the get form tag
<form id="choosetype" action="createpost" method="get">
variables and form in mysite/createpost:
<?php $postType = $_GET['choosetype']; $postTax = $_GET['choosetax']; if($postType == 'my_cpt_1' && $postTax == 'my_tax_1' || $postTax == 'my_tax_1'):?> <form action="publish" method="post" enctype="multipart/form-data"> <?php elseif($postType == 'my_cpt_2':?> <!--- Another form ----> <form action="publish" method="post" enctype="multipart/form-data"> <!--- And so one ---->
there, everything works great…
but in the next step when I use
wp_insert_post(). no parameters has been passed to:
'tax_input'=> array('custom_tax' => $postTax) and to:
'post_type' => $postType.
Despite I define the variables before. What should I do?
Already thanks for your help.