I am customizing a wordpress plugin which is used for popup email subscribing. when the user submits email he gets a confirmation email in which iam sending my custom html to him. I have five different pages on my web site and every page has that popup. what iam doing is that i want to get the name of my page than according to that i want to send html in email. I did exactly the same thing for other plugin and it worked but in this popup plugin iam unable to get the page name from where it is called.
I have tried following things but failed.
global $post; /* this worked perfect on other plugin */
$pagename = $post->post_name;
if($pagename=="page1")
{
// html page1 //
}
else
{
// html page2 //
}
Just tried this
$slug = basename(get_permalink());
if($slug=="page1") and so on
Here you go, you need to get
title
for this, asHope it helps.
The best way is to use get_queried_object. It retrieve the currently-queried object – page, post, taxonomy, whatever…
You can try this code, its working for me:
Please try to use this: