WordPress.org

Make WordPress Core

Opened 3 years ago

Closed 3 years ago

#15686 closed feature request (worksforme)

Detect the current page template tag

Reported by: numediaweb Owned by:
Milestone: Priority: normal
Severity: normal Version: 3.1
Component: Template Keywords: get_current_page pagenow
Focuses: Cc:

Description

It would be of a great use, specially for theme developers, to add a get_current_page template tag for Wordpress. A function that detects the current page, because now the only solution is to use the core variable $pagenow such as:

if ($pagenow == 'wp-login.php' )

as we know; using global core variables is not a good practice, but until now there's no other solution.

Change History (1)

comment:1 nacin3 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to worksforme
  • Status changed from new to closed

It's fine to reference globals. Using pagenow is quite common in fact.

That said, there's the $current_screen object, which if you prefer, has its own getter, get_current_screen(). This was introduced in 3.0 and includes much more information and context than pagenow.

Note: See TracTickets for help on using tickets.