Make WordPress Core

Opened 8 years ago

Last modified 5 years ago

#34487 new enhancement

Add a new conditional tag for the "Posts Page"

Reported by: roytanck's profile roytanck Owned by:
Milestone: Priority: normal
Severity: normal Version: 4.4
Component: General Keywords: has-patch
Focuses: Cc:

Description

Currently, there's no conditional tag to determine whether the current page is the "Posts Page", set under Settings->Reading. The codex (https://codex.wordpress.org/Conditional_Tags#The_Blog_Page) describes a way to combine is_home() and is_front_page(), but I propose that we instead add a new conditional tag to deal with this.

Naming the function is a little tricky. Unfortunately, the name "is_posts_page" is taken in query.php, so I created a patch that adds "is_blog_page". It returns true on the "posts page", and false everywhere else.

I've run across this issue in real world projects a couple of times and though it would be a good addition to WordPress. The patch adds this to query.php because is_home() and is_front_page also live there.

Attachments (2)

is_blog_page.diff (1.7 KB) - added by roytanck 8 years ago.
Patch that adds the is_blog_page conditional tag to query.php
rt-testplugin.zip (769 bytes) - added by roytanck 8 years ago.
Plugin to test the is_blog_page conditional. Adds a message to the_content that displays whether the current page is the posts page.

Download all attachments as: .zip

Change History (4)

@roytanck
8 years ago

Patch that adds the is_blog_page conditional tag to query.php

#1 @roytanck
8 years ago

  • Keywords has-patch added

@roytanck
8 years ago

Plugin to test the is_blog_page conditional. Adds a message to the_content that displays whether the current page is the posts page.

This ticket was mentioned in Slack in #core by roytanck. View the logs.


8 years ago

Note: See TracTickets for help on using tickets.