you can retrieve the permalink of the current post in JavaScript with wp_localize_script.
juste try this code after the call of wp_enqueue_script
wp_localize_script(
"script_id"
, "object"
, [
"permalink" => get_post_permalink($post),
]
);
and then you can read the permalink in JavaScript in object["permalink"]
Related Posts:
- Ajax Load More Posts in Category Page
- Ajax post doesnt call succes after got the response
- Colorbox not working on native WordPress gallery when gallery is loaded thru AJAX
- Dynamically update post title in admin page
- How to load post content on index page using ajax when post title in sidebar is clicked
- POST from jQuery to PHP
- “Uncaught SyntaxError: Unexpected token
- Add confirmation popup on “Move to Trash”
- The correct way to call posts with ajax
- How do I use Ajax to show the new posts realtime, on the frontpage
- How to create a load more post entries like Twitter?
- Ajax load more button in Recent posts widget
- Ajax Dynamic Archives not showing correct results
- WP_Query with ajax handler returns the same posts
- Ajax post filters not working
- Ajaxify This Code
- Genesis + Ajax + Jquery | Failling to call action
- Using the loop to set locations for all posts on a single google map
- Many buttons not functioning in WordPress dashboard (as admin)
- WP Load post with ajax and apply isotope
- Get post id on click of thumbnail
- Cross-Origin Read Blocking (CORB)
- jQuery get textarea text
- How to generate a simple popup using jQuery
- What does on() in JavaScript do?
- AJAX response error: net::ERR_EMPTY_RESPONSE
- jQuery Ajax POST example with PHP
- SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data
- How to make comments work for a post loaded per Ajax?
- Enable Submit Comment Without Page Reload (Using Ajax)?
- How to create WP Editor using javascript
- Can I load posts via Ajax?
- Custom plugin giving: wp-admin/admin-ajax.php 400 (Bad Request)
- Show Custom Taxonomy Categories, Listing of Posts, and Single Post via AJAX
- Trying to get single posts to load on the front page via ajax
- This AJAX Code Doesn’t Work – Looking for elegant solution
- Ajax not firing properly using Firefox, but works in Chrome
- Handling an Ajax form submit
- admin-ajax.php HTTP400: BAD REQUEST – The request could not be processed by the server due to invalid syntax
- How to create popup same as wordpress popup feature
- How to speed up admin-ajax.php in wordpress
- Sending jsPDF documents to the server
- AJAX filter posts by year
- WordPress customizer refresh screen after save
- How to test nonce with AJAX – Plugin development
- Ajax Modal Flickers When Opened Multiple Times
- How to pass Post_ID variable from theme’s Single.php to custom Plugin using AJAX
- Custom post preview without saving
- Correct way to write jQuery functions in WordPress
- Block Editor: Reset Reusable Blocks to last saved record
- Scripts not appending to element in AJAX call – why?
- Two loops, one AJAX loop, exclude posts in first loop from second loop, loops are in different files
- JS innerhtml changing style when using AJAX
- How to Dynamically Load Content Into Body of Bootstrap Modal Window?
- How to add a do_action on refreshing of WP customizer?
- Loading post with Ajax
- Random ajax load only works with posts_per_page set to -1
- Trouble with WordPress Ajax Login System – 302
- How to add a Custom Mailchimp AJAX Newsletter Subscribe Form
- Display wordpress post’s in popup?
- Fancybox type popup window that’s not an iframe
- Dynamic dependent Dropdown lists for categories, sub-categories and posts
- Do all wordpress themes a similar class name for content?
- AJAX fileupload – TypeError: not a function ajaxSubmit()
- Security to delete post by Admin
- url – ajax loaded but no JS
- add bootstrap post slider with tabs
- In post.php how can I remove onbeforeunload?
- Load Posts on Click via Ajax into a DIV
- Navigate through the posts using keyboard arrows
- Why i can’t get custom fields value or post ID via Ajax?
- datepicker value in mysql
- Accessing an API with jQuery and AJAX
- Using AJAX and PHP to load next post object
- Insert specific information to a posts of a predefined category
- Why is it recommended to insert JS through the theme, plugin, etc rather than in the post directly?
- WordPress React re-rendering to many times
- Passing values via an Ajax querystring
- React to AJAX adding to the page
- how to filter posts by category without page load (ajax) in wordpress?
- WP Ajax returning 0, can’t find action
- How to echo a PHP code into WooCommerce variation product?
- How to call a function from functions.php with ajax?
- number of posts with “Load More”
- Get ajaxForm response value
- Order result from ajax
- Loading posts outside wordpress
- Dynamically load posts based on category
- Find the method which AJAX GET calls
- Ajax the create and edit post form into lightbox and get results
- Front end post delete error confirmation and success message
- Retrieve customizer value using ajax or customizer api and print the value in theme
- Run Jquery Script after delete post in front end
- jquery: getting contents of #content field on post page
- Full width images within post content
- Widget won’t work due to old JavaScript? Any ideas how to make it work? [closed]
- How to make ‘show_option_all’, that comes from wp_list_categoreis, to work with get_categories or with get_terms?
- How do I save JS classes being applied to the WP dashboard via custom plugin?
- I got this error POST https://localhost/meraboilerwp/[object%20Object] 404 (Not Found)
- JQuery UI Autocomplete/Autosuggest WordPress