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)
- My javascript is returning this error: $.ajax is not a function
- ajax jquery simple get request
- jQuery AJAX cross domain
- Set timeout for ajax (jQuery)
- jQuery AJAX submit form
- How can I upload files asynchronously with jQuery?
- Adding images to a Bootstrap Carousel with AJAX
- Refresh/reload the content in Div using jquery/ajax
- Keyboard shortcut for updating a page or post?
- How to load paginated post pages via ajax
- Get the current post ID as a variable in Javascript
- Getting the post_id in wp_ajax function
- Load posts dynamically
- Drag and drop multiple file upload using Ajax WordPress
- Turn jQuery.ajax() request into XMLHttpRequest (vanilla JavaScript)
- Working Bootstrap Carousel Conversion to WP – Technical Questions
- WordPress theme ajax have_posts()
- Create a separate JS application for an individual post?
- Display notification only once
- Access/update database with jQuery
- Add scripts on custom post add/edit pages Not Working
- Colorbox ajax loading of outside HTML content works perfect on localhost but not on server
- AJAX Contact Form Issue
- Disable Jquery UI post tabs
- Ajax return code 400
- jQuery inluclude still seems ncessary for script to work within post
- how to set beforsend option in wordpress ajax methods
- class click counter save number
- WooCommerce Ajax Cart Update Stopped Working
- How to search using ajax for exact phrase or words in an input field?
- Integrate OpenStreetMap on WordPress
- Setting value of session with Ajax not working
- AJAX not Working with php as supposed
- Post repeating with infinite scroll
- Load Next Posts With AJAX not working with custom post type
- videopress videos are not displayed when loading the content with ajax in a lightbox
- Auto-realod with new posts // Ajax call
- WordPress Ajax Call inserting data but success response false
- How to return multiple arguments from AJAX callback function
- Dynamically switch template on click
- Use Click Image to Play Youtube Video in a WordPress Loop
- Ajax Validation for reCaptcha
- wp_query with ajax
- Incrementing PHP variable onclick to display posts by month
- After ajax image is outside the “ tag
- Retrieve post in AJAX Callback
- Adding JS functionality to the Publish button in wp-admin/post.php
- Get content from WordPress posts in Boostrap modal window – Javascript side?
- Is there some jQuery conflict here?
- WordPress cascading dropdown selection search based on Parent Page & Child Page
- Uncaught TypeError: Cannot read properties of undefined (reading ‘message’) [closed]
- Post form – AJAX won’t upload featured image – Plugin development
- javascript onClick update user_meta from jquery.ajax
- Running JavaScript after using WooCommerce Filter Plugin
- How to use wp_ajax_set_post_thumbnail?
- Unable to delete attached file from folder programmatically
- Javascript – How do I get specific post fields?
- Cannot successfully execute AJAX script to call function.php specific function. Using XAMPP localhost to test
- Multiple Notifications SetInterval
- Orderby post__in Not Working Correctly?
- Custom plugin giving: wp-admin/admin-ajax.php 400 (Bad Request)
- Blog Post slider not working
- WP_Query extended with AJAX
- Ajax – Post Categories and Load More
- problem with creating a wordpress post slider
- 500 (Internal Server Error) of external php file
- Displaying contents of a tab
- Problem with jQuery in post body?
- How to get posts from network blog
- Ajax, jQuery and WordPress
- Dynamic Gallery
- Adding a time stamp on post view
- Load css classes after using ajax calls
- Pass a PHP variable (loop-audio.php) to jQuery function (js/script.js)
- WordPress Ajax send response on every iteration of a loop
- How can I add a custom caclulation form in post?
- WordPress Ajax load doesn’t work
- AJAX call not initializing for non-admins in WordPress