Skip to content

Instantly share code, notes, and snippets.

@johnregan3
Last active July 21, 2016 17:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save johnregan3/59c83ab27b7d5319a174624f66ec2067 to your computer and use it in GitHub Desktop.
Save johnregan3/59c83ab27b7d5319a174624f66ec2067 to your computer and use it in GitHub Desktop.
Registering a Custom Post Type with the WP AMP plugin
<?php
/**
* Register CPTs to be included with AMP integration.
*
* Be sure to visit Settings > Permalinks and save twice
* to ensure the rewrite rules are flushed after adding this.
*
* @action amp_init
*/
function jr3_amp_register_post_types() {
if ( ! defined( 'AMP_QUERY_VAR' ) ) {
define( 'AMP_QUERY_VAR', apply_filters( 'amp_query_var', 'amp' ) );
}
add_post_type_support( 'book', AMP_QUERY_VAR );
}
add_action( 'amp_init', 'jr3_amp_register_post_types' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment