WordPress.org

Make WordPress Core

Opened 4 years ago

Last modified 4 months ago

#34487 new enhancement

Add a new conditional tag for the "Posts Page"

Reported by: roytanck Owned by:
Milestone: Priority: normal
Severity: normal Version: 4.4
Component: General Keywords: has-patch
Focuses: Cc:
PR Number:

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 4 years ago.
Patch that adds the is_blog_page conditional tag to query.php
rt-testplugin.zip (769 bytes) - added by roytanck 4 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
4 years ago

Patch that adds the is_blog_page conditional tag to query.php

#1 @roytanck
4 years ago

  • Keywords has-patch added

@roytanck
4 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.


4 years ago

Note: See TracTickets for help on using tickets.