1

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?

3
  • Yes, you can do AJAX programming. Now what is the question, really?
    – s_ha_dum
    May 8, 2014 at 14:02
  • Okay you got me, added the real question to the bottom. May 8, 2014 at 14:06
  • 1
    We have a one question per question rule, anything other than your main focus can you split it off so that they can be answered separately? If you don't then your question won't get as many answers and runs the risk of being too broad ( what if someone declines to answer because they have an answer for the first question but not the second? )
    – Tom J Nowell
    May 8, 2014 at 14:15

2 Answers 2

2

WordPress is an HTTP/PHP web application. The ordinary rules of HTTP and PHP apply, and work. WordPress itself uses $_POST and $_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.

1

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',
)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.