Skip to content

Commit 01d8da1

Browse files
committed
Treat attachment feed as a real rss feed
1 parent 9a0077b commit 01d8da1

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

plugins/bcc-attachments-rss-feed/bcc-attachments-rss-feed.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,9 +116,19 @@ public function render_feed() {
116116

117117
add_filter( 'posts_where', array( $this, 'filter_where' ), 10, 2 );
118118

119+
// Flag this secondary query as a feed query (is_feed = true) so access-control
120+
// plugins (e.g. BCC Login) recognize it as a feed and apply their feed-key
121+
// bypass. Without this, the query is treated as a normal archive query and the
122+
// content-access visibility filter hides any attachment that isn't explicitly
123+
// set to "Public" — even when a valid feed key is supplied.
124+
//
125+
// WordPress overrides 'posts_per_page' with 'posts_per_rss' for feed queries
126+
// (see WP_Query::get_posts), so 'posts_per_rss' must be set to preserve PER_PAGE.
119127
$query = new WP_Query( array(
120128
'post_type' => 'attachment',
121129
'post_status' => 'inherit',
130+
'feed' => self::FEED_SLUG,
131+
'posts_per_rss' => self::PER_PAGE,
122132
'posts_per_page' => self::PER_PAGE,
123133
'paged' => $paged,
124134
'orderby' => 'date',

0 commit comments

Comments
 (0)