WordPress.org

Ready to get started?Download WordPress

Forums

How to send a parameter to custom template in address line? (2 posts)

  1. Tarlan
    Member
    Posted 2 years ago #

    Sorry for my broken English.
    I've created a custom template and a page with it. My permalinks have the structure "/%category%/%postname%/". I want to send a parameter to my page (template).
    If to write "mysite.com/thepage/1234/" (where "1234" is any number), the page opens up. I can get this numeric parameter using php-variable $_SERVER['REQUEST_URI'].
    If to write "mysite.com/thepage/a1234/" or "mysite.com/thepage/1234/5678/", I get "the page you requested cannot be found".
    So I have questions. Why WordPress accepts only one numeric parameter? Is it a parameter indeed? How to send more then one not-numeric parameter to my template? Is there any functions for this? If that is impossible then is my method to get parameters permissible?

  2. vtxyzzy
    Member
    Posted 2 years ago #

    Multiple parameters are passed after the page URL like this (assume http://yoursite/yourpage/ is the URL to get to the page):

    http://yoursite/yourpage/?param1=value1&param2=value2

    You get the values in the template using the $_GET array:

    $param1_value = (isset($_GET['param1'])) ? $_GET['param1'] : 'default param1';

    Here is an excellent reference on query strings:

    http://en.wikipedia.org/wiki/Query_string

Topic Closed

This topic has been closed to new replies.

About this Topic