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
- Get the ID of the latest post
- Change permalinks for posts but not for custom post types
- Front end post editing using a form
- Set posts of a custom post type to be private by default?
- WordPress post sorting with AJAX
- How make get_next_post() return first post when viewing last one
- modify all posts of a category to “no comments allowed”
- Getting a div content of a post in wordpress?
- How can I add dropdown widget/box to admin post page?
- Custom permalinks – post type – hierarchical taxonomy’s
- How to show related posts by category or custom post type?
- ascending order custom post type
- add_meta_box: Datepicker like the one for postdate?
- [Plugin: Posts 2 Posts] Changing display order of connections
- Display taxonomy term only if there’s a value
- How to show post title outside of loop? [closed]
- How do you use JavaScript to detect the homepage
- How to delete all posts from a custom post type?
- Update content of multiple pages/posts at once?
- Display types of posts in edit.php instead of All, Published, Scheduled and Draft
- get_queried_object error How to show post count by month in the taxonomy page
- CPT’s archive and single page not working [closed]
- Trying to edit the single page from a Custom Post
- How to Submit Post Via cURL & PHP
- apply filters only to specific post listing without check the url parameters
- is there a way to retrieve posts that do not have a featured image assigned?
- Deleting Custom Post type data using mySQL command
- Received nothing after executing AJAX post function
- Loading custom content type from ajax results?
- convert custom query to wp_query
- Post image in WordPress not appearing on home page
- WP_Query inside foreach loop returning same value for all options when filtered using ajax
- Custom Post Slug same as Parents Category Slug
- Load Custom_post_type categories post with ajax
- How to get all tags of a custom post type by id
- How to define which register_post_status goes to which register_post_type?
- How to sort posts in a custom post type by title in ascending order by default?
- Conditional for a Single Post That Belongs to a Category?
- Create new custom post and post category of same name
- If there is only one post (show elements) else (show other elements)
- Display Only Certain Category In a Custom Page Template
- Custom post type menu
- filter by custom taxonomy using ajax
- passing values from functions.php to template
- Modify Posts from Custom_Post_Type within the plugin
- How do I edit the WordPress post.php file?
- Posts are not rendering perfectly [closed]
- How I can made a custom post type to page templates?
- List all posts in taxonomy term
- how to redirect to a custom post template
- Post/Custom Post Type URL Access
- Create a custom post type based on ‘Post’
- Adding /blog in front of single posts (only)
- Ajax Post Filter | Split Taxonomy Into minPrice & maxPrice
- See if the email exists or not
- list articles in admin showing nested categories or slugs?
- How to set post date in post_type so that it’s same as latest post in category
- Search CPT by tag ids
- Post template with breadcrumb needs to show page navigated from
- Define multiple prefixes for custom post type
- Publishing failed. The response is not a valid JSON response
- add all blog posts to folder
- Show posts from WP Custom Post Type selected from a field in a metabox
- order custom post type posts by custom date
- How to show posts of the same category on a page?
- custom post type to post association in wordpress
- Need to display author’s email id in the “Edit post” field in wp dashboard. How do I do this?
- Update 2 wordpress tables at once
- How to get all posts related to a taxonomy?
- call a function when insert and update a custom post type
- How to use costum database table for custom post type
- Work and Display a Custom Post Type as a normal Post
- Most efficient way of showing children posts?
- How to add New Post On clicking a button?
- Custom post type with two templates
- One Post with different content, depending on a Page
- Custom Post Type
- Popup panel is only displaying 1 entry ignoring all others
- Custom Post Status & Taxonomies
- How to display data with pagaination on backend?
- Edit post meta direct from post.php?
- How to Arrange Support => Thumbnail
- Front-end form submission not creating post
- Query Distinct Taxonomies of Custom Post Type
- Search page for custom post type
- Post being scheduled that shouldnt be schedulded
- how to remove user name and date in post page
- Get custom post type parent category
- How to delete unnecessary custom post types in the UI
- show the most recent date of all posts to display on front end
- Canot save post if any meta box was empty
- Error 403 when posting comments to a custom post type from a different page
- How to automate the creation of advanced layout article/post
- Sort ACF by custom taxonomy