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
<?php if (have_posts()): while(have_posts()): the_post(): ?>
<a href="http://example.com/gallery?my_gallery_id=<?php echo $post->ID; ?>">Gallery</a>
<?php endwhile; endif; ?>
So with just the URL you would have:
http://example.com/gallery?my_gallery_id=<?php echo $post->ID; ?>
Related Posts:
- posts page – different lengths of excerpt
- how to show all post in my page-grid.php template page
- Single post as homepage?
- Switch to page template when using post permalink
- Get Page ID of blog homepage
- Why won’t pagination work?
- Prevent 404 of Author pages without posts
- Single Sidebar; multiple templates! How?
- Is it possible to query a category with specified posts?
- My blog “page” used to show a list of posts, but now it’s just showing the page content?
- How to arrange different post categories in template
- how to style an individual page in a category [duplicate]
- Redirecting posts in WordPress to a specific page
- custom post type single page template not working
- WordPress “Posts Page” isn’t showing template dropdown
- Get current menu_order
- get_children() Not Working with orderby Parameter
- Post/Page Publish/Update button not clickable once I make an edit
- Custom Field in Featured image for A particular post
- Is there a WordPress equivalent to MediaWiki templates
- Is it possible to show a different WP menu when using password protected pages?
- Multiple loops in same page, without duplicate content
- why does HTML Tag not working in Post and Page
- problem to delete page
- Including text at the end of every post
- Redirect before post page
- $post object is null
- How to display different single post template based on author?
- Is there any WordPress alternative to Book module of Drupal?
- Convert a complex webpage into WP theme
- Display page content AFTER a loop of posts
- Trying to edit the single page from a Custom Post
- Change post_date to post_modified date on post template?
- Should a photo gallery be in a post or on a page?
- Multiple loops are not reset
- Drag posts and pages so you can sort them in order
- Setting posts_per_page for taxonomy term template
- 301 (static page instead latest posts)
- Send post id through ajax and get the post content back
- How to create new post content templates for my users?
- Start post pagination at 0 instead of 1
- Using wp_list_pages() after calling query_posts()
- Proper way of establishing custom landing pages in WordPress
- Hide a specific post from a page template
- is_page Funtion for Posts ?
- WordPress Query Posts From Category Post on Static Page
- Create a custom posts page
- Intercept page request and add value to it
- get_children returns older images
- Detecting current page from class method
- Single post full screen template not inheriting WordPress role permission
- Change Author Name to Sitename on Frontend
- Showing recent post of category in page
- Trying to query all posts in category 4
- Create a frontpage.php and static page template
- Have posts included on a page that share same category
- Preview page/post revisions without overwriting current content
- Link from Post to Another Post Via Clicking on Words within Original Post
- Link to older links
- How to show next/prev link, when it’s not active?
- Custom post type and taxonomy page templates
- What would causes search to return incorrect results?
- Can I restore restore content from old Worpress site to a new Worpress site from an archive
- How to save template data into wp_post table (post_content column)
- Edit post & page option does not display on latest wordpress
- How to show only homepage in google results instead of privacy, contact pages
- Add CSS and JS files of the template post on a WordPress page
- Can’t find webpage on All Pages or All Post menus
- Show post count in custom taxonomy page
- Display all tags even if they are not assigned to a post
- how to put post customized in page
- Show code only on WooCommerce Pages
- Multiple Pages – Seperate blogs
- Category URL to use same string as Post URL Permalink
- Posts on Sidebar only
- Posts are not showing up on next page.
- How to give priority to page than to posts permalink structure?
- single- and archive- templates not being applied to custom post types, not even after flushing permalinks
- Hide Admin posts & pages in Dashboard
- structure of posts and pages
- how to remove entry meta from wordpress archive category and change its display
- Display only current page -> posts tags in page
- Call posts of particular category in a page
- Add wp-link-pages to post
- How to mix pages and sub-categories in a url
- How can I change the look of a post as is displayed
- Make a custom URL and link to custom Template
- Display the first post’s comments of category in comments.php template
- How to Post to Specific Pages?
- associate posts to a page
- How to display a certain template element only for posts published within certain time range?
- Woocommerce – custom post type of checkout page
- Posts and pages not getting published
- How to have more post in a page than in your home page
- How do I create a template page to show 3 blog posts?
- CSS – Change height of Storefront / WooCommerce product categories, but not products
- How to add a new page that will function as a separate blog/news article page
- Cannot Create a new Post [closed]
- Automatically search and replace link in content (pages/posts)?
- How to remove slug from CPT correctly?