Skip to content

Instantly share code, notes, and snippets.

@gregrickaby
Last active August 29, 2015 14:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save gregrickaby/ac57d7d3f46647644824 to your computer and use it in GitHub Desktop.
Save gregrickaby/ac57d7d3f46647644824 to your computer and use it in GitHub Desktop.
Make a CPT post sticky anytime it's updated
<?php
add_action( 'save_post', 'child_sticky_factory', 99 );
/**
* Allow sticky posts in a CPT
*/
function child_sticky_factory() {
$post_id = get_the_ID();
$stickem = get_post_meta( $post_id, '_child_sticky', true );
if ( 'some_post_type' != get_post_type( $post_id ) ) {
return;
}
isset( $stickem ) ? stick_post( array( $post_id ) ) : unstick_post( $post_id );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment