How to get current page name in wordpress?

by dalton_moen , in category: PHP CMS , a year ago

How to get current page name in wordpress?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

Member

by lily , a year ago

@dalton_moen 

To get the current page name in WordPress, you can use the following code:

1
2
global $wp;
$current_page_name = $wp->request;


This code uses the global $wp variable to access the current request and gets the current page name by accessing the request property. You can store the page name in the $current_page_name variable for further use.