| 开发者 |
whodunitagency
leprincenoir |
|---|---|
| 更新时间 | 2026年9月30日 20:27 |
| PHP版本: | 8.2 及以上 |
| WordPress版本: | 7.1 |
| 版权: | GPLv2 or later |
| 版权网址: | 版权信息 |
sticky_posts option, exactly like sticky posts: is_sticky() works out of the box.
Start example
$args = array(
'post_type' => ['project'],
'post_status' => 'publish',
'posts_per_page' => -1,
'post__in' => get_option( 'sticky_posts' )
);
$stickyProject = new WP_Query( $args );
Hook available
add_filter( 'sticky_cpt_add_cpt' , 'add_cpt' );
function add_cpt( $post_types ) {
$post_types['newcpt'] = 'newcpt';
return $post_types;
}
/wp-content/plugins/sticky-cpt directory, or install the plugin through the WordPress plugins screen directly.custom-fields support?No. Since 3.0.0 the block editor uses the native sticky field of the REST API. Your custom post type only needs show_in_rest to use the block editor.
Users who can both publish and edit others' contents of the custom post type, the same rule WordPress applies to posts.
sticky_value_cpt post meta, what should I do?This meta was removed in 3.0.0. Use is_sticky( $post_id ) or get_option( 'sticky_posts' ) instead.
Enable "Sticky posts" in the Polylang synchronization settings. Until 2.0.0 the sticky state was carried by a custom field, so it followed the "Custom fields" synchronization. Since 3.0.0 it only follows the "Sticky posts" synchronization.
When the Polylang "Sticky posts" synchronization is enabled, a bulk edit that leaves the "Sticky" field on "No Change" unsticks the edited contents and their translations. This comes from Polylang (observed with Polylang 3.8.10) and also affects regular posts, with or without this plugin. Until it is fixed in Polylang, select "Sticky" explicitly in the bulk edit form when all the selected contents are sticky, or stick them again afterwards.
sticky REST field, the custom-fields support is no longer required for the block editor.sticky_value_cpt post meta is removed and deleted on update. Use is_sticky() or the sticky_posts option.sticky_posts option and wrong sticky counter.wp.editor.PluginPostStatusInfo.