I am use to php development in general and I am use to getting a lot done by making a
POST to a php file. However I have not seen people using
$_POST in WordPress. I have seen one discussion about someone wanting to create new posts on their blog using
$_POST, and they were directed to a more secure system. (Perhaps I misunderstood the conversation though.)
I would still like to use
$_POST simply as a part of the user interface.
If it is possible and not a horrible idea to use $_POST what do I need to know to make $_POST work well with WordPress? Are there rules about making a $_POST, or how redirecting so that nothing interferes with WordPress behavior? Are there any other special considerations?
WordPress is an HTTP/PHP web application. The ordinary rules of HTTP and PHP apply, and work. WordPress itself uses
$_GET more times than I can count. If you want to pass information from one page to another– say from a form to a search handler– you have to use one or the other.
There are some helper functions like
add_query_arg() that might be applicable but as written your question is too broad to allow for specifics.
It’s worth mentioning that if you’re implementing your own
$_POST/GET variables, make sure you avoid conflicts with built-in WordPress ones:
array( 'm', 'p', 'posts', 'w', 'cat', 'withcomments', 'withoutcomments', 's', 'search', 'exact', 'sentence', 'calendar', 'page', 'paged', 'more', 'tb', 'pb', 'author', 'order', 'orderby', 'year', 'monthnum', 'day', 'hour', 'minute', 'second', 'name', 'category_name', 'tag', 'feed', 'author_name', 'static', 'pagename', 'page_id', 'error', 'comments_popup', 'attachment', 'attachment_id', 'subpost', 'subpost_id', 'preview', 'robots', 'taxonomy', 'term', 'cpage', 'post_type', 'post_format', )