@toscho for starters I got some code that's working and beeinb shown and validated by monkeyman-rewrite-analyzer, and before when i typed http://kurdaktuellt.se/galleri/images/1598/ I got a page not found, now i just get to the http://kurdaktuellt.se/galleri/
–
BreezerOct 3 '12 at 5:04

your code works fine in default twentyeleven theme. var_dump the $wp_query global and verify that it exists. have you flushed rules since adding the query var? you'd get a 404 if the rewrite hasn't been picked up, but the fact that the rewrite doesn't 404 suggests the issue is elsewhere in your theme.
–
MiloOct 3 '12 at 15:06

@Milo I'm suspecting the rewrite is working as mentioned in the Q:n but what my issue is to be more precise to get get_query_var('images') working which is not...
–
BreezerOct 3 '12 at 16:00

1

again, it works fine in twentyeleven, echo get_query_var('images') outputs the correct value, your issue is not with the above bit of code you've posted.
–
MiloOct 3 '12 at 16:07

@Milo hmmm have to take alook at it ... thanks for the help
–
BreezerOct 3 '12 at 16:11

1 Answer
1

My initial thought without being able to do further testing is that your custom galleri page is looking for the URL parameters in order to determine which post to pull images from. However, since you're rewriting the URL, those URL parameters don't technically exist (I could be wrong about this - I'm not at a spot where I can do testing and I don't know your exact code).

If your goal is to have user friendly URLs, you could go with a different approach than URL parameters. You could get the value of the $_SERVER["REQUEST_URI"] variable, split it on the "/" and determine the post from there.

I'm using this solution atm but it's not what I'm after, I mean why doesnt get_query_var('images') work?
–
BreezerOct 3 '12 at 6:35

When you use the URL that has the URL parameters, it does work from what you're saying. However, when you use the code that you listed above to rewrite the URL, the URL parameters don't technically exist for get_query_var to pull. Hence, you'd need to change the way you're trying to get the number, per my answer above.
–
Phil ErbOct 3 '12 at 13:56

It's definitely an interesting issue and not one that I would have foreseen when planning out to do what you're doing.
–
Phil ErbOct 3 '12 at 13:56

I added some PHP code to my answer that should help you in reading the "friendly URL" to get the information you need.
–
Phil ErbOct 3 '12 at 14:56

I appreciate you helping but as i was saying i already have that solution and to add a bit to it if someone ever cares to use it, you should count the array cause its not definitive that someone will use a trailing slash at the end I'll give you a point for the try but its not the answer im looking for im sorry
–
BreezerOct 3 '12 at 15:58