Last active
August 29, 2015 14:01
-
-
Save gregrickaby/ac57d7d3f46647644824 to your computer and use it in GitHub Desktop.
Make a CPT post sticky anytime it's updated
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 | |
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