在wordpress中获取当前页面类型

I need to get cuurent page type.

Whene I use this func out of any other function it works !

function get_current_page_name(){
    if (is_home() || is_front_page())
        return 'is_home';
    else 
        return 'is_page';
}

But whene I use it like this in home page

function my_function(){
    echo get_current_page_name(); /// returns 'is_page'
}

This functions calls with ajax

I checked it and it seems to work for me.

Can you specify what version of WordPress you are using? Are there any plugins installed? And where exactly do you put this code.

In my test case I added this to my functions.php file.

function get_current_page_name(){
    if (is_home() || is_front_page())
        return 'is_home';
    else 
        return 'is_page';
}

function my_function(){
    echo get_current_page_name();
}

And this to my index.php file.

<?php
    my_function();
?>

This works.

If I will choose home page to some static page in WordPress settings, and put the same but in page.php file it still works and returns is_home