If I understand correctly- this is an AJAX request, there is no $post var because you haven’t loaded anything from the database in this request. You have to pass both the ID you want to relate it to, and also the ID you want to relate it from, neither exist in the current request.
Related Posts:
- Storing posts from query and accessing later via AJAX call
- How to add a custom-post-type post within another custom-post-type post edit screen using AJAX?
- JS innerhtml changing style when using AJAX
- Load Next Posts With AJAX not working with custom post type
- Load Next WordPress Posts With AJAX?
- WordPress notification if new post published
- Hide load more button if no more post in selected category
- Passing total post count to javascript
- Default post showing more than intended
- Add extra parameters after permalink?
- AJAX search on post pages by custom post type
- Limit the word count in the post title
- Correct Post Count ( All | Published | Drafts | Pending | Trash ) for Custom Post Type when restricting to view own posts
- Get terms that contain posts that in turn belong to other terms?
- Filtering custom posts with Ajax
- How do I write this SQL statement for Posts written in last 24 hours?
- 960gs different classes on teasers posts
- Full-Ajax Theme: parseJSON error while building a JSON object from a WordPress custom template
- Structuring a product catalogue in WordPress [closed]
- How can I fix a slow redirect after form submit from frontend (no plugin)?
- Change Post Title Edit Box
- Inserting data into `post meta` table?
- Multiple information using custom post type
- Disable feeds for specific custom post types
- Disabling post_type in URL
- Before Delete Post
- Making pages also serve as taxonomies? Or give full pages to taxonomies?
- Why does using WP_Query inside a shortcode in an elementor page cause the arguments for WP_Query to get malformed?
- Check Title Unique Or Not and If not error message and dont save
- I am having a problem with form updating/editing WordPress post on the frontend
- How to filter the taxonomy terms based on another taxonomy term
- Why my custom post posts aren’t showing (404 error / page not found)
- Automaticly add slug to posts
- Shortcode for display posts on home page show only one post
- How to Separate CPT From Regular Posts?
- Remove rows in the manage post/page view
- Display only one post each WEEK
- AJAX load more for different custom post type loops
- Set a checkmark in a category based on a URL-parameter
- Portfolio Page for Classic Posts
- Custom post type editor with dynamic selects, one drop down populating a second second drop down not working
- Get terms that contain posts that in turn belong to other terms?
- Limit the post for differents custom post type in the same wp_query
- Some posts from custom post type to subdomains
- how to check if custom post title exists or not?
- Modify previous and next post links to current Authors Other posts
- Custom post type’s extra fields – how to handle?
- WPDB for post count on post
- Display an authors post on a single page only when they are logged in
- Get_the_terms restrict output
- Generate new post from email
- YOAST SEO won’t work on custom post type archive [closed]
- Batch Extract Date from post title and put into ACF custom field
- How to add new post using a form to categories when categories are using as menu
- Custom wordpress loop
- Different post title, keywords and description
- how to get options to choose post format in add new post
- How do I update_post_meta() or add_post_meta() with an AJAX call
- Use post in multiple places on a page with multiple posts
- $wpdb is queried but results don’t show
- Change Post Meta via AJAX from the posts list table
- Making a form for user to add new custom post with custom taxonomies and custom fields
- Custom post type filter is being applied to all of my posts
- Admin slow on Postlist (over 30k Posts in Database)
- Get_post_custom not fetching value from array wordpress
- Display Parent-Child Posts in specific order by comparing IDs in array
- Post category behave like a Post in back office menu
- Save data is post using php front end
- What is the best way to structure posts for the same event happening in different years?
- How to display custom field in product description?
- WordPress – display relationship between blog posts and custom posts
- How to submit the date with ajax?
- Custom page with no headers, footers and its own CSS, Javascript
- SEARCH QUERIES – REVERSE OUTPUT
- Is there a way to create a sidebar of bullets
- Get queried object for custom post type count
- edit.php all post not working
- I cannot display custom posts in custom taxonomy
- Ajax load more inside custom post type taxonomy
- How can I get the last 5 element of this tax query?
- How to get the posts that my following users are liked?
- How to insert post 6 times after user register like ask.fm
- How can i order my posts by post type?
- Creating custom post type relationships
- How to mark posts as visited
- Collect custom post in a calendar
- How To Loop Through list with Custom Post Types
- Adding Information To All Posts Screen
- Different post types arranged on one page
- erase post excerpt limitation [×]
- Display all post types together
- $wpdb returns no results with SELECT query on custom post type, works on default post type
- Pulling in a particular post into a single page based on the post id passed into the code
- Custom My account page and custom page for editing posts
- Get post from custom post type that title is like custom string [closed]
- show posts under custom post type with same autj
- How Do I Add a Custom Post Type URL to Content?
- is therer any wordpress function to retrieve a specific html element from post content
- Load posts via AJAX without draft status
- button onclick with get_post_permalink