WordPress.org

Ready to get started?Download WordPress

Forums

Check if editing post or page? (2 posts)

  1. nielskreijveld
    Member
    Posted 4 years ago #

    Hey people,

    I'm wondering if there is any way to check if one is editing a page or a post from the WordPress backend. I've added some custom boxes to the post/page edit page, but I'd like to show some of these only on the add/edit post page, and some on the edit/add page screen. Is there any way to achieve this?

    Thnx!

  2. JesperT
    Member
    Posted 4 years ago #

    This?

    if(strstr($_SERVER['REQUEST_URI'], 'wp-admin/post-new.php') || strstr($_SERVER['REQUEST_URI'], 'wp-admin/post.php') || strstr($_SERVER['REQUEST_URI'], 'wp-admin/edit.php')) {
        //Post
    }else{
        //Page
    }

Topic Closed

This topic has been closed to new replies.

About this Topic