Created
June 15, 2023 11:46
-
-
Save janboddez/13c181e9662aef465375caf86632ff3e to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
/** | |
* Modify likes' URLs, and add tagging. | |
*/ | |
add_action( 'register_post_type_args', function( $args, $post_type ) { | |
if ( 'indieblocks_like' === $post_type ){ | |
$args['rewrite']['slug'] = 'bookmarks'; // The new slug. | |
} | |
$args['taxonomies'] = array( 'post_tag' ); // Allow likes to be tagged. We're using the default "post" tags rather than a custom taxonomy. | |
return $args; | |
}, 99, 2 ); | |
/** | |
* Modify likes' default template. | |
*/ | |
add_action( 'init', function() { | |
$post_type_object = get_post_type_object( 'indieblocks_like' ); | |
if ( ! $post_type_object ) { | |
// Post type not active. | |
return; | |
} | |
$post_type_object->template = array( | |
array( | |
'indieblocks/bookmark', | |
array(), | |
array( array( 'core/paragraph' ) ), | |
), | |
); | |
}, 99 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Turns the IndieBlocks' "like" CPT into more of a "bookmark" CPT. Make sure to visit Settings > Permalinks afterward!