You don’t need a query if you the know the post ID:
<?php
$post_id = absint( $_POST['post_id'] );
if ( ! $post = get_post( $post_id ) )
exit; // Error
if ( $post->post_status !== 'publish' )
exit; // Might want to prevent script kiddies from accessing private content
echo '<h4>' . get_the_title( $post ) . '</h4>';
Related Posts:
- Inject post (from specific category) between posts in Loop
- Count number of published posts by type
- Get taxonomy terms only of the WP_Query current posts
- Hide post if matches current month and year
- How can I use wp_query to show all product data using just the products ID?
- How to store post ID’s in cookie or session to display the same posts later
- WP_Query: getting posts where custom field exists
- Array to string conversion on array_map
- Store metakey value as an array
- Increment paged on WP_Query
- Modify main query before it run without pre_get_post
- Do not duplicate posts with multiple categories in multiple loops
- array_rand not working correctly?
- Wp Query : Order by distance lat,lon
- WordPress sorting posts by date and title using a dropdown
- posts_per_page displays only 2 posts instead of 4 posts
- Query on a repeater date (acf)
- Need to show 7 posts from actual date
- Check the database for a postmeta field
- Getting info about selected posts using one WP_Query
- How to display last whole post on the homepage
- Only Get A Certain Number of Posts From WP_Query
- insert thumbnail image from php script
- Weird Behaviour: Not all WordPress Posts appearing
- List of child pages fetch next results at link click
- Query category-specific, paginated posts and allow viewer to change sort order
- Why does WP_Query show only the same post even with different categories and endwhile?
- How to modify this function to exclude also the post belonging to a specific category?
- How to use a conditional statement in a post loop but not count towards the “posts_per_page” if false
- How do I use WP_query with multiple post IDs?
- Disable Attachment Pages Completely
- is_page() not working from within a plugin
- Passing JSON data from WP Query into AJAX causing NULL errors
- How to add 2 posts under another post? Formatting should be intact
- Print number of post (in reverse)
- Can an array be used as a meta_query value?
- Can’t increase posts_per_page by variable
- How to get 2 or multiple custom post types in wordpress functions.php
- Displaying a button on each post
- Creating bulk posts with Youtube videos
- Getting a specific post values to another div or modal
- get current custom post ID by WP_Query method
- Create WP_Query to search for posts by their categories or their parent/child categories
- how do I get a specific post from a post with a subcategory in WP
- Open post-content in archive page in a Modal box with bootstrap
- Redirect to another page using contact form 7? [closed]
- Fatal error: Call to a member function query() on a non-object
- How to avoid duplicates when creating recent network posts
- Update post title from external file?
- set post limit at load more ajax wordpress
- Trouble inputting variable into WP query
- WP_Query | IF within $args array | Help me only add specific arguments if the argument is not blank
- Target post_date_gmt if it’s empty or not set
- How to use mysql LIKE with wpdb?
- Get all posts as an array ID => Name
- Do I need to edit my theme in order to change the title of my blog page?
- Passing an array into WP_Query as a variable
- Custom query vars filters problem with pagination
- WordPress meta_query >= &
- Incrementing PHP variable onclick to display posts by month
- Dividing the loop to style post differently
- Wrap posts p tags in div
- WordPress SQL JOIN query
- WP_Query and help with the loop for magazine front page
- How to WP_Query posts order by parent title?
- search.php to search only the post title
- Generating 10 000 WordPress posts using PHP and avoiding Server Timeout error
- If Post Published Date or Modified Date is 1 Year or Older, Display Notice on Post Page
- Filter wordpress posts without searching the keywords in the post content
- wp_Query with mutuplea values returns all posts
- Use WPQuery to match to specific repeater row in post
- WP_QUERY post_in problem
- How to get post titles by post ID and integrate with my code?
- how to get data from two different table from wordpress database
- Assign meta_query value to php variable
- Infinite looping next post link within a certain category on a post
- WordPress search query, how to modify the sql
- Modify post image in full size
- How to use a PHP file to control the content of a blog post
- Custom Post By Category
- Making list of posts with chosen description
- Ordering / grouping posts by datepicker ACF
- Include search tags and users in my search results system
- Add custom taxonomy to custom search for posts
- Using Tag Groups: Displaying groups and adjacent tags of current post
- My query keeps looping infinitely ! how to stop it?
- How to add thumbnails from recent posts to owl-carousel in wordpress automatically?
- Display 6 most recent post on homepage?
- Apply filters when loading post via ajax
- Querying posts based off a jquery datepicker
- How to call post title and post summary to other part of site?
- Published custom posts missing
- Use custom get results query to show posts WordPress
- Add Custom Post Type on the Fly or create an array
- WordPress article with 50 000 words loading slow – 100% cpu
- Display post of specific category on page
- WP query with variables gives no result for specific user
- Display all categories (with link) of custom post type – WordPress
- Add adjacent post function inside custom recent post function
- How do I exclude the current post from the upcoming post query