Skip to content

Instantly share code, notes, and snippets.

@thefuxia
Created May 22, 2012 00:47
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save thefuxia/2765738 to your computer and use it in GitHub Desktop.
Save thefuxia/2765738 to your computer and use it in GitHub Desktop.
Newsfeed for post type 'page'
<?php # -*- coding: utf-8 -*-
/**
* Plugin Name: T5 Page Feed
* Description: Adds a feed for pages at <code>/feed/?post_type=page</code>.
* Version: 2012.05.22
* Author: Thomas Scholz
* Author URI: http://toscho.de
* License: MIT
* License URI: http://www.opensource.org/licenses/mit-license.php
*/
add_action( 'pre_get_posts', 't5_pages_in_feed' );
/**
* Set post type to 'page' if it was requested.
*
* @param object $query
* @return void
*/
function t5_pages_in_feed( &$query )
{
if ( isset ( $_GET['post_type'] ) && $_GET['post_type'] === 'page' && is_feed() )
{
$query->set( 'post_type', 'page' );
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment