Skip to content

Instantly share code, notes, and snippets.

@lucagrandicelli
Created October 24, 2018 11:08
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 lucagrandicelli/3eadfef00800a9f4837dfaf3edf24f25 to your computer and use it in GitHub Desktop.
Save lucagrandicelli/3eadfef00800a9f4837dfaf3edf24f25 to your computer and use it in GitHub Desktop.
How to register a Custom Post Type with the YARPP (Yet Another Related Posts Plugin) in Wordpress
<?php
/**
* This is the method to register a custom post type adding YARPP support in it.
*
* @param $data array The original CPT args.
* @param $post_type string The CPT slug.
*
* @return array
*/
function register_my_cpt() {
// Preparing args.
$args = array(
'public' => true,
'label' => 'Books'
'yarpp_support' => true,
);
// Register my Custom Post Type.
register_post_type( 'book', $args );
}
// Adding wordpress action hook.
add_action( 'init', 'register_my_cpt' );
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment