I have a post gallery and I’m displaying the thumbnails in example.com/gallery. Now this thumbnails are created via posts and when you click on on eof the thumbnails, it will direct you to single.php template. It goes to display a gallery room which mimics a Gallery Exhibit created with HTML5 and CSS3. Its quite heavy to load and doesn’t really have the standard web gallery feel and I want an option for users to click weather to view it in Gallery Room or the standard grid which the native WordPress Gallery has.
Now I want, in my example.com/gallery, to have two links. One on the Gallery Room and one on the standard grid. But how can I do this? I have already created a template for the standard gallery but how can I dynamically get the ID of the post whenever the user click on the 1st link in the example.com/gallery page.
I have this in my template:
$post_id = 527;
$queried_post = get_post($post_id);
527 being the post ID. But of course this is not dynamic. I want to pass that ID to a url by clicking a link and will be stored to a variable which will be the value of the $post_id.
Can anyone help?
thanks!
When clicking a link from a post to a page you can concatenate the post_id to the end of the link as a GET variable.
So let’s say you had a link within the WordPress loop you can easily add the post_id as a GET variable as such
So with just the URL you would have: