How to get current page name in wordpress?

by dalton_moen , in category: PHP CMS , 5 months ago

How to get current page name in wordpress?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

Member

by lily , 5 months 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.