Created
October 24, 2018 11:08
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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