the another way to get the post_id
by clicking on the link
is to add a data-attribute
to the link. e.g; data-post-id="'.get_the_ID().'"
your html code should look like
<a href="#link" data-post-id="47">Link</a>
then in your js code above the ajax call
var post_id = jQuery(this).attr('data-post-id');
and pass this in your data
object to the ajax call.
data: ({
action: "get_prev_ajax_handler",
url: url,
post_id: post_id,
}),
now you can get the post_id
with $_POST['post_id']
or print_r()
the $_POST
array()
Related Posts:
- Get plugin directory from a theme
- WordPress Plugin Development In MVC Architecture, How?
- Rewriting every url
- category_name not working (not showing up in sql query debug)
- How can I make my custom shortcode work in a Custom HTML Widget?
- What happens when two plugins have the same 3rd party class included into them?
- add_rewrite_rule, plugin activation and plugin deactivation
- Custom admin column disappearing when using Quick Edit [duplicate]
- Create page when plugin is activated
- Update Multiple Post Meta for the Same Post In One call?
- Allowing Custom Capability to Manage Plugin Options
- wp_insert_user – how to send verification email before logging in
- Custom plugin settings: clicking “save changes” does not display success message
- How to un-attach rich text editor from named textarea elements
- How can I translate the name of my Plugin for other languages?
- How to load a new template page according to a particular URL?
- how to not show plugin in admin area
- Memory Leak in plugin action
- Getting User email on logout. wp_logout
- Ajax call doesn’t work in frontend but it’s working in backend (when I’m logged in)
- How can I filter blog name?
- Logs to check when the plugin was first installed for the first time
- Can a plugin add to header/footer/body content?
- Detect if a plugin was included in a certain page
- Override the core function locate_template
- How Can A Plugin Hook Itself To the End of Every Excerpt?
- Allow Facebook to preview posts before published
- Admin page: form with enctype=”multipart/form-data” does not transfer its data
- Set user ID at time of wp_create_user
- add action for displaying posts using a shortcode
- Best way to hook a custom url?
- How do I add a custom sub menu menu under Woo-commerce marketing?
- How to load plugin after page is loaded – pagespeed issues
- Do action only on certain front end pages?
- How to create custom tables in WordPress using my own plugin?
- How would I go about creating a user ranked post popularity page?
- How to modify WCMP Rest API response?
- Making a Template for a CPT created by a plugin
- Woocommerce dependent plugin
- External CSS in WordPress Plugin [closed]
- User Session and Stored Cookies not get removed
- Create a navbar filter that filters by a custom field
- get 404 when accessing wp-admin/plugin-install.php
- Woocommerce Minimum Price for a Composite Product to add in cart
- add tabs in rdp-plugin/includes/settings.php and get settings saved
- Customised plugin failed to install and activate
- Plugin Development Form Self Submission
- Why is one phpunit test throwing an error on one class when all other classes are similar without error?
- How To Extend A WordPress Plugin Without Losing Your Changes [duplicate]
- Does a blank plugin come with any overhead?
- Admin AJAX doesn’t work in plugin admin page – Even though code is copied verbatim from WordPress Codex
- WPDB: Update table
- Why is my custom post type not being activated on plug-in activation?
- How to get all posts belongs to a user between a certain date
- Check filter defined or not?
- How to generate an all in one WordPress New content, plugin and theme update report on a website? [closed]
- Why WP_Screeen doesn’t show all options with admin_body_class
- License validate function
- wp_enqueue_style on template_redirect level?
- Built a second plugin but it overwrote the first one
- How to delete all categories programatically?
- How to use custom Javascript code inside a plugin?
- Adding submenu to custom plugin menu page created with add_menu_page() function
- What is necessary to secure a WP plugin against direct file access attempts?
- why the wp_register_script doesn’t work for register_activation_hook
- Add a Custom Field in Comment Box next to the Text area
- How do you create a re-useable HTML fragment in wordpress
- How do i ‘deactivate’ a plugin only on a certain page template?
- Set Button in PluginDocumentSettingPanel Content (WordPress Gutenberg)
- GitHub plugins safe to use in my website?
- Personality quiz in wordpress using a plugin
- How can we get this dynamically as this folder may not be by the same name always → wp-admin
- woocommerce: Customize email with item total count
- Why is my shortcode not working?
- The styles in the recent posts widgets plugin not working
- How to get the checkout form data from checkout page when place-order button is clicked
- Link custom post type to page
- implement checkbox or toggle switch in plugin code
- wp_remote_post To external API multiple values with the same key
- wordpress form not saving or updating
- How to put a maximum real-time users limit
- Custom admin plugin read CSV
- How can I call functions from a custom plugin?
- How to get short description under heading – Visual Composer [closed]
- plugin installing error
- Why the output of an image gallery plugin is not displayed into a page of my custom theme?
- How can I use wp_ajax_response for front-end error reporting?
- How can I insert a record into a custom table from my custom form in my custom admin page?
- how to create table during plugin installation in side a class
- WP_Filesystem usage within a block of code
- Force download a file within plugin file
- How can I use multi Media Uploader in a plugin?
- Is it possible to run javascript on plugin deactivated?
- Gutenberg: Dynamic Block – Show saved data in the editor
- How to fix ‘Call to undefined function do_settings()’ error?
- add_meta_box showing blank screen in my page
- Plugin translations are not loaded from translate.wordpress.org
- Use inline callable for hooks and filters
- Error in using ‘admin_enqueue_scripts’ action through a class
- How do i fix this error?