0

Do any of you know a way to check if the current page is the permalink admin page?

2
2
<?php
// 'current_screen' action fires after the current screen has been set
add_action( 'current_screen', 'my_check_current_screen' );

// $current_screen is WP_Screen object passed by the 'current_screen' action
function my_check_current_screen( $current_screen ) {

    // compare current screen ID to the string of your choice
    if( 'options-permalink' === $current_screen->id ) {
        echo 'I am on the "Permalink Settings" screen';
    }
}

You can check what you can play with using the 'current_screen' action instead of global $pagenow:

add_action( 'current_screen', 'my_print_current_screen_object' );

function my_print_current_screen_object( $current_screen ) {

    echo '<pre>';
    print_r( $current_screen );
    echo '</pre>';

}
1

Try below lines into your function.

global $pagenow;
echo $pagenow; // This should give you current page of admin page
1

I don't know exactly what you want to do. But basically, you can use:

is_page( 'contact' ) // To see if this page is the page contact

is_singular( 'post' ) // To see if this is a spefic post type

get_permalink() // To get the permalink of a post inside the loop

global $pagenow // To get the page you are now

If you explain better what you want, it is easier to offer a better answer.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.