• Resolved Steve Kimpton

    (@stevekimpton)


    I’m mystified by the behaviour of twentytwelve on my site.

    If I create a tiny form on a test page as below via the editor everything is fine:

    <form action=”list”>
    <input type=”submit” name=”submit” value=”submit” />
    </form>

    But if I create the form via a shortcode on a page whose slug is ‘searchform’, with apparently identical code appearing on the resulting page, I get one of those “This is somewhat embarrassing…” messages because the page requested is …/searchform/list.

    All the pages are ‘ordinary’ pages with no parents and use the default template.

    Anyone know what is happening and how to deal with it?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter Steve Kimpton

    (@stevekimpton)

    I’ve realised that the code produced by my shortcode wasn’t exactly as above, it included ‘method=POST’ for the form and that’s what was causing the problem. The default form method is GET and that works.

    So the problem is shifted.

    There are several forum posts about forms failing with method=POST but no explanations or solutions that I can find.

    Any advice gratefully received!

    Thread Starter Steve Kimpton

    (@stevekimpton)

    It turns out that I can make the link work with any of these

    <form action=”list”>
    <form action=”list” method=”GET”>
    <form action=”../list” method=”POST”>

    but they are all wrong! We are supposed to use an action URL found with a WordPress function, for example:

    $target=site_url(‘/list/’);
    <form method=\”post\” action=\”$target\”>;

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Relative links from form created by shortcode’ is closed to new replies.