Skip to content

Instantly share code, notes, and snippets.

@janboddez
Created June 15, 2023 11:46
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 janboddez/13c181e9662aef465375caf86632ff3e to your computer and use it in GitHub Desktop.
Save janboddez/13c181e9662aef465375caf86632ff3e to your computer and use it in GitHub Desktop.
<?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 );
@janboddez
Copy link
Author

Turns the IndieBlocks' "like" CPT into more of a "bookmark" CPT. Make sure to visit Settings > Permalinks afterward!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment