1

I have a fully-functional WordPress site with a URL structure like this:

http://example.com/friendlyurl/

But I would like to be able to pass an ID number like this (or whatever URL structure would work):

http://example.com/friendlyurl/?id=123

I have a custom page template that will handle everything from there, I just need a simple way to get the number to the page template. I.e.:

$id=trim($_GET["id"]);

I am not a WordPress whiz, just looking for a simple solution here to solve a problem. Would appreciate any advice or direction.

Thank you!

BB Design
  • 695
  • 12
  • 26
  • 2
    What you are suggesting should work fine - what problems are you getting – Steve Oct 06 '14 at 14:53
  • When I try to pull in the variable's contents, I don't get anything. I do an "echo" and its just blank. Its always possible I have a problem with that part of the code, I was not assuming my URL would work with WordPress. – BB Design Oct 06 '14 at 14:57
  • Hmm, seems you are correct, not used wp for a while. Take a look here for possible solutions: http://stackoverflow.com/questions/4586835/how-to-pass-extra-variables-in-url-with-wordpress – Steve Oct 06 '14 at 15:09
  • 1
    http://codex.wordpress.org/Function_Reference/add_query_arg – Robert Lee Oct 06 '14 at 15:21
  • @RobertLee Unless I'm misunderstanding, that function just lets you modify a URL, it doesn't do anything to accept an incoming query variable value? – BB Design Oct 06 '14 at 15:40
  • Oddly enough, it was not working before, but seems to now. I'm not sure what I changed. So my original URL is fine to use like that? – BB Design Oct 06 '14 at 15:43
  • If all your trying to do is pass the number in an ID then you would want to use add_query_arg to add that id value and pass it to the link you are trying to send that value to. – Robert Lee Oct 06 '14 at 15:44

0 Answers0