• First, thank you for any insight you may be able to offer.

    I am trying to build a “non-blog”, yet PHP/MySQL-driven section on my WordPress blog, using two “pages”–one for the “List View” and one for the “Item View”.

    I made a 2nd MySQL database table and populated it with data.

    I made a new Page that queries the specific DB table and displays the results in a list.

    The problem is trying to pass dynamic values onto the “Item View” page.

    What I normally do is pass on values through the URL string, like this:

    detail_page.php?value1=somevalue&value2=somevalue

    But this does not work in WordPress, since it does not use file name extensions.

    I tried this…

    <a href="detail_page?value1=somevalue&value2=somevalue>
    [no .php extension]

    …but that didn’t work either.

    Any help would be greatly appreciated.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Moderator bcworkz

    (@bcworkz)

    WordPress uses extensions, it’s disguised by the permalink feature, but there are extensions. Note the backend links often have extensions AND url parameters. WP translates permalinks like example.com/post-title-slug/ internally to a normal url like sample.com/index.php?p=344 where 344 is the post ID of the post known as “post-title-slug”.

    If your detail_page.php is a file that actually exists in the server filesystem, passing parameters as you show will work. If it’s really a WP “page” that is a special type of post and does not exist in the filesystem, you can append url parameters to the permalink and the template code can retrieve the parameters as usual with $_GET, for example: sample.com/detail-page/?value1=somevalue&value2=somevalue

    Even if you omit the trailing slash before the parameter separator (?), the rewrite system should add it back in, provided /detail-page/ is a legitimate permalink for your page.

    Are you sure you don’t have some syntax error preventing the url parameters from working? Because they should work.

    Thread Starter Sal Barry

    (@sal-barry)

    Hi bcworkz,

    Thank you for your reply.

    Here is a little more detail about the problem.

    I have a page called “Wrappers”. It uses the Pages Sidebar Template and has a conditional that checks the URL. If the URL = “pages”, it goes to the DB and populates a bunch of images and links on the page. This is working fine, but here is a link to that page:

    https://puckjunk.com/wrappers/

    If you look at that page and click on one of the images in the content area, it should take you to the “Wrappers Detail” page (which also uses the Pages Sidebar Template). The parameters are being passed along just fine, but the PHP code on the page is not running.

    At least if I got an error message, I’d know that the “Wrappers Detail” page is reading my shoddy code. But the script is not running, so I’m stumped.

    Thank you again for reading all of this.

    Sal

    Thread Starter Sal Barry

    (@sal-barry)

    OK, it seems that the ? and parameters and such in the URL are casing it to redirect to the 404 page.

    When I type in the URL to the “Wrappers Detail” page, it runs some simple PHP I put on the page for testing purposes.

    Moderator bcworkz

    (@bcworkz)

    There seems to be some issue with your url parameters being related to an actual detail page. Assuming the wrapid would be enough to find a page, I put in /wrapperdetail/?wrapid=151 and got the simple php page. Only when I included the other parameters does a 404 come up. It appears it can’t find a page that matches the other parameters. I don’t know what you’re really doing with these, I’m just reporting how it appears.

    I guess all I’m saying is the ? and wrapid parameter seem to work, thus parameter passing in general works, the problem is in how the other two parameters are used.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Passing values in the URL from page to page’ is closed to new replies.