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
- Implement AJAX ‘load more’ with offset posts
- Cross-Origin Read Blocking (CORB)
- Cross-Origin Read Blocking (CORB)
- syntax error: unexpected token <
- Infinite Scrolling in Asp.Net MVC with jQuery / AJAX Issues
- My javascript is returning this error: $.ajax is not a function
- ajax jquery simple get request
- jQuery get textarea text
- jQuery AJAX cross domain
- Set timeout for ajax (jQuery)
- How to generate a simple popup using jQuery
- What does on() in JavaScript do?
- call to jquery ajax failing with 500 error when passing extra data field
- Javascript output now showing in custom widget
- Post data across WordPress sites
- How to echo a PHP code into WooCommerce variation product?
- How can i get the same ajax result using WP REST API instead of admin-ajax?
- How to call a function from functions.php with ajax?
- Multiple Notifications SetInterval
- number of posts with “Load More”
- Orderby post__in Not Working Correctly?
- Filterable posts using categories
- Custom plugin giving: wp-admin/admin-ajax.php 400 (Bad Request)
- Get ajaxForm response value
- How to submit form data in the same page in WordPress without reloading the page?
- Blog Post slider not working
- AJAX load more posts not using correct category and repeating the same few posts
- Order result from ajax
- Ajaxify Post Sort
- testing result of $.post with json_encode
- Loading posts outside wordpress
- Dynamically load posts based on category
- Find the method which AJAX GET calls
- WP_Query extended with AJAX
- Ajax the create and edit post form into lightbox and get results
- How do I use slideToggle inside a wordpress post?
- Printable Page with all Posts from Tag
- Automatic add space if user enters number(any digit)
- Why I’m Not Having Access to “$_POST” Data Outside My AJAX Callback?
- Ajax – Post Categories and Load More
- Front end post delete error confirmation and success message
- problem with creating a wordpress post slider
- Retrieve customizer value using ajax or customizer api and print the value in theme
- 500 (Internal Server Error) of external php file
- Displaying contents of a tab
- Problem with jQuery in post body?
- Run Jquery Script after delete post in front end
- How to get posts from network blog
- Ajax, jQuery and WordPress
- Dynamic Gallery
- Adding a time stamp on post view
- jquery: getting contents of #content field on post page
- Load css classes after using ajax calls
- Ajax calls in wordpress
- Full width images within post content
- Pass a PHP variable (loop-audio.php) to jQuery function (js/script.js)
- How to hide a script ( an ad) from a specific post? [closed]
- Widget won’t work due to old JavaScript? Any ideas how to make it work? [closed]
- WP Rest API feature image breaking react component
- notify users when changed database
- WordPress Ajax send response on every iteration of a loop
- How can I add a custom caclulation form in post?
- 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?
- WordPress Ajax load doesn’t work
- AJAX call not initializing for non-admins in WordPress
- iOS and ajaxComplete
- I got this error POST https://localhost/meraboilerwp/[object%20Object] 404 (Not Found)
- Code understanding
- Passing total post count to javascript
- Default post showing more than intended
- JQuery UI Autocomplete/Autosuggest WordPress
- How to show custom fields in modal in category page
- Xhr.send : PDF upload failed with status 400 and response 0
- How to make Contact Form 7 work when injected via AJAX in WordPress?
- Gutenberg block: add a multi-select for posts
- Ajax load more post button not showing
- /wp-admin/admin-ajax.php Error 500 while using divi premade layout in existing pages
- How do I ensure that the URL parameters are updated correctly when multiple filters are applied