最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

plugins - How to get a specific string from a url

programmeradmin0浏览0评论

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 badges
Add a comment  | 

1 Answer 1

Reset to default 0

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/get-current-page-slug-wordpress/

发布评论

评论列表(0)

  1. 暂无评论