WordPress – Permettre les sticky posts pour les custom post types – Allow Sticky Posts for CPTs

Permettre sticky-posts sur des custom post types

Enable sticky-posts in wp-admin for Custom Post Types CPT

functions.php


/**
**
**
** Sticky formations-gratuites ou formations-membres **/
add_action( 'admin_footer-post.php', 'gkp_add_sticky_post_support' );
add_action( 'admin_footer-post-new.php', 'gkp_add_sticky_post_support' );
function gkp_add_sticky_post_support()
{ global $post, $typenow; ?>
<?php if ( $typenow == 'formations-gratuites' OR 'formations-membres' && current_user_can( 'edit_others_posts' ) ) : ?>
<script>
jQuery(function($) {
var sticky = "<br/><span id='sticky-span'><input id='sticky' name='sticky' type='checkbox' value='sticky' <?php checked( is_sticky( $post->ID ) ); ?> /> <label for='sticky' class='selectit'><?php _e( "Stick this post to the front page" ); ?></label><br /></span>";
$('[for=visibility-radio-public]').append(sticky);
});
</script>
<?php endif; ?>
<?php
}

Author: bejisan

Share This Post On