Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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