WordPress.org

Ready to get started?Download WordPress

Forums

Using PHP GET with custom template (4 posts)

  1. glidez
    Member
    Posted 7 years ago #

    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?

  2. makebbekus
    Member
    Posted 7 years ago #

    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?

  3. Mark Jaquith
    WordPress Lead Dev
    Posted 7 years ago #

    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

  4. makebbekus
    Member
    Posted 7 years ago #

    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

Topic Closed

This topic has been closed to new replies.

About this Topic