Skip to content

Instantly share code, notes, and snippets.

@mikeschinkel
Created June 6, 2012 23:49
Show Gist options
  • Save mikeschinkel/2885558 to your computer and use it in GitHub Desktop.
Save mikeschinkel/2885558 to your computer and use it in GitHub Desktop.
Custom URLs for Comic Feed, see: https://github.com/Frumph/comic-easel/issues/2
<?php
/**
* Written to help @Frump with https://github.com/Frumph/comic-easel/issues/2
*/
class Comics_URL_Class {
static function on_load() {
add_filter( 'init', array( __CLASS__, 'init' ) );
add_filter( 'request', array( __CLASS__, 'request' ) );
add_filter( 'feed_link', array( __CLASS__, 'feed_link' ) );
}
static function init() {
register_post_type( 'comic', array(
'public' => true,
'label' => 'Commics',
'rewrite' => array(
'with_front' => false,
'slug' => 'comics',
),
));
}
/**
* request sets the $wp->query_vars array so WordPress will know what query to run and what theme templates to load.
*
* @static
* @param $query_vars
* @return array
*/
static function request( $query_vars ) {
if ( 'comics/feed' == $pagename ) {
$query_vars['feed'] = 'feed';
}
return $query_vars;
}
/**
* feed_link provides the feed URL when WordPress or a theme calls get_feed_link().
*
* @static
* @param $output
* @param $feed
* @return mixed
*/
static function feed_link( $output, $feed ) {
// You may need to change output here
return $output;
}
}
Comics_URL_Class::on_load();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment