I am creating a custom WordPress theme and i am little stuck in one situation . what i want is that http://192.168.1.50/jobifylocal/resume/paulwoods/ get the name : paulwoods in a $variable. Note every-time there is new name instead of paulwoods, when i click on a post. Does anybody have a clue how can i get it ? I searched on google but no relevant problems found, and also i don't have any clue to do that.
I am creating a custom WordPress theme and i am little stuck in one situation . what i want is that http://192.168.1.50/jobifylocal/resume/paulwoods/ get the name : paulwoods in a $variable. Note every-time there is new name instead of paulwoods, when i click on a post. Does anybody have a clue how can i get it ? I searched on google but no relevant problems found, and also i don't have any clue to do that.
Share Improve this question asked Aug 28, 2020 at 11:44 JainJain 297 bronze badges1 Answer
Reset to default 0I 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/get-current-page-slug-wordpress/