I believe you should be able to use this:
global $post;
$page_slug = $post->post_name;
Where $page_slug is the variable you’re looking for. This has a pretty good explanation of why that works: https://blog.wplauncher.com/get-current-page-slug-wordpress/
Related Posts:
- Is it possible to filter the wp_footer() scripts, read the content, and insert them inline?
- Pass a php string to a javascript variable
- wordpress site | All-in-one-cufon IE Issue
- Using window.onload with Ubermenu
- Redirect to another page using contact form 7? [closed]
- wordpress add_action() issue in ajax call
- How do I output user_registered time in my correct timezone?
- Thumb rating for wordpress – top user
- Ajax call doesn’t work in frontend but it’s working in backend (when I’m logged in)
- Add jQuery to WordPress page
- How to use wp-ajax in wp-cron
- How do I use WordPress PHP functions in my Javascript code?
- How can I make the “Preview Post” button save and preview in the same window?
- Difference between register_block_type & wp.blocks.registerBlockType
- how to include a simple jquery file into a wordpress plugin
- Problem in loading javascript in footer
- add mediaelement.js plugins into WordPress video player control bar
- Shortcode button dosent work for all posts. Work for first post only
- Accessing post’s meta data based on user’s click of a post
- Best approach to fetch data from wp options to js file or php file
- Adding a slider captcha to the comment system
- How to put JQuery/Ajax inside shortcode?
- Can someone please tell me what is wrong with my plugin?
- WordPress function not being called from jQuery method
- How to get the element ID from new menu list that added with add_filter()?
- Override Plugin Script Fucnction in WordPress
- Time consuming callbacks in customizer
- Modifying a .js Function for Print [QZ Tray, WooCommerce POS]
- How to edit content before post update
- How to call WordPress function other files
- How to insert HTML/JavaScript form into WordPress page? [closed]
- How to get my plug-in, wrote in php, to refresh on its own every 5 minutes?
- How to prevent plugins from loading jQuery
- Using TinyMCE in plugin?
- How to include this jQuery File in wordpress?
- How to Loop Through all Posts and Count Attachments using Get Media Attachments
- Localizing methods for jQuery append prepend wrap parent
- JQuery prepend a function
- Return multiple values in a shortcode attribute
- get specific value of a array | PHP
- coding a WordPress AJAX Form using PHP to check if User is Logged Out and Show error
- Save user total active time after login in wordpress [closed]
- Why does my jQuery plugin show up as text in WordPress?
- Disable submit button order
- Custom meta box with jQuery.sortable custom post type list
- Load CSS files in header of Bones theme?
- JS Plugin not executing the js correctly. Trying to make all internal links scroll smoothly
- Call javascript functions from each page
- Javascript from Easy-Fancybox place into footer
- uncaught TypeError: Cannot read properties of null (reading ‘classList’) custom plugin
- Custom Plugin scripts from admin working in frontend
- Ajax call not working in wordpress through a plugin
- Woo-commerce Update price as a Bulk from My offline software export
- Jquery POST Ajax Return null data in wordpress
- WordPress jQuery Post – Amending Variable Value Within Function Command
- how to display recent post by category on home page
- Overriding inline !important CSS with Javscript code snippet with media query
- WP Ajax DB issues
- Get the link title attribute and send it google analytics as custom label via google tag manager using beehive pro for WordPress
- Calling PHP function with AJAX
- How to properly enqueue jQuery knob on WordPress without conflict?
- Ajax Call not Working in Plugin
- front end editor creation for Restropress plug in – displaying information from a WP admin area, on a different URL
- update_post_meta is not working for me when I use e.preventDefault for update button
- Website always load twice on start
- Multiple image selection custom widget
- Custom Field used to allow a Free Story; no longer works
- Create a form and have custom menu display based on user answers?
- How to solve Blocked a frame with origin from accessing a cross origin frame error in wordpress?
- Speeding up WordPress on a Local Network
- How to use information from the database in the front-end?
- Conditional Fields depending on checkboxes
- Custom plugin giving: wp-admin/admin-ajax.php 400 (Bad Request)
- Help with customising love it plugin (use within foreach)
- Number format in thousands on highcharts in wpdatatable plugin
- Embed Javascript code to registered users only
- Javascript in plugin not working
- Trending Tags based on post views
- Media Playlist Plugin
- How to set up php,javascript and css to allow for our finished product to be displayed within a page?
- What is the process for reimplementing a back up WordPress?
- Possible jquery / library conflict in plugin usage
- Ajax, jQuery and WordPress
- Hyperlink to execute PHP
- How to get site homepage from plugin?
- Why won’t the Comprehensive Google Map Plugin load?
- PHP and Jquery pass value from form. Update function on DataBase
- get_option include in my adsense
- Can’t insert files in other inputs
- Plugin use of ajax/jquery depending dropdown
- Ajax in Plugins: returns the whole page
- Load css classes after using ajax calls
- Javascript as Jquery Function Call?
- wordpress jquery is not defined because the head tag is empty
- Adding a script & php to functions.php
- how to show selected options drop down menu values in attributes field in after saving post.php
- Refresh server side rendered block in Gutenberg without changing attributes or its content
- How do I call an action hook into wp_ajax hook callback function
- I want to display data last 7 days with date wise in chartjs?
- Accessing Correct Database to Create REST API Endpoint