WordPress.org

Support

Support » How-To and Troubleshooting » Using PHP GET with custom template

Using PHP GET with custom template

  • I created a new template so I can add my own PHP script but the script uses the html submit button with the PHP GET method and I dont have a php page to direct it to. When I load the page with the new template all I see in the URL is the directory name and no php page.. yet the directory does not exist when I connect to my server via FTP. Does wordpress dynamically link the url with the directory name to a php page? How does that work? How could I get around this, if I want to use GET?

Viewing 3 replies - 1 through 3 (of 3 total)
  • I’m having a similar issue, but haven’t found a solution yet. I’ve created a WordPress Page called ‘Photography’ that uses a template file I have written. The template file (php) brings in one my flickr set based on the get value. e.g. photography.php?s=456487984654. But because the Page address is http://mysite.com/photography there is no .php file to amend it to. If I try directly sending it to photography.php I get defaulted to my WP search results page with no results.

    Anyone figured out to use the GET method with Pages?

    Moderator Mark Jaquith

    @markjaquith

    WordPress Lead Dev

    WordPress’ pages (and any of its URLs that don’t contain .php) are virtual… they don’t correspond to physical directories.

    You should be able to append ?get=foo to a WordPress page URL and then access $_GET['foo'] within your custom page template.

    Note that s is used by WordPress for WP searches, so you’ll want to choose something else like ?flickrsearch=X

    Thanks markjaquith! As soon as I changed the variable name everything started working as expected. To finish my example from above for anyone else having issues, the working address looks like this:

    http://mysite.com/photography/?set=234234234

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Using PHP GET with custom template’ is closed to new replies.
Skip to toolbar