Marking future dated post as published

Awesome combining both the answers from Mike and Jan I came up with this which works only on the post type in question. We don’t need the conditional of show because the ‘future_show’ hook only grabs the post type of show and updates that. <?php function setup_future_hook() { // Replace native future_post function with replacement … Read more

Where, When, & How to Properly Flush Rewrite Rules Within the Scope of a Plugin?

The best place to flush rewrite rules is on plugin activation/deactivation. function myplugin_activate() { // register taxonomies/post types here flush_rewrite_rules(); } register_activation_hook( __FILE__, ‘myplugin_activate’ ); function myplugin_deactivate() { flush_rewrite_rules(); } register_deactivation_hook( __FILE__, ‘myplugin_deactivate’ ); See the codex article Apologies in advance, I didn’t make it all the way through your question, so this is a … Read more

Query by post title

You can use either search parameter of wp_query : Code $args = array(“post_type” => “mytype”, “s” => $title); $query = get_posts( $args ); Or you can get posts based on title throught wpdb class: global $wpdb; $myposts = $wpdb->get_results( $wpdb->prepare(“SELECT * FROM $wpdb->posts WHERE post_title LIKE ‘%s'”, ‘%’. $wpdb->esc_like( $title ) .’%’) ); Than you’ll … Read more

Get The Post Type A Taxonomy Is Attached To

If we peek into the global $wp_taxonomies variable we see the associated object types. There might be better ways to do this or even core functions, but you could try the following: function wpse_172645_get_post_types_by_taxonomy( $tax = ‘category’ ) { global $wp_taxonomies; return ( isset( $wp_taxonomies[$tax] ) ) ? $wp_taxonomies[$tax]->object_type : array(); } then for the … Read more

Remove custom post type slug from URL

That’s how you can do first part of the job – get rid o CPT slug in post link (eg. news post type). function df_custom_post_type_link( $post_link, $id = 0 ) { $post = get_post($id); if ( is_wp_error($post) || ‘news’ != $post->post_type || empty($post->post_name) ) return $post_link; return home_url(user_trailingslashit( “$post->post_name” )); } add_filter( ‘post_type_link’, ‘df_custom_post_type_link’ , … Read more

Customize Edit Post screen for Custom Post Types?

Some of these questions are answered here: Set Default Admin Screen options & Metabox Order To remove the permalink metabox: function my_remove_meta_boxes() { remove_meta_box(‘slugdiv’, ‘my-post-type’, ‘core’); } add_action( ‘admin_menu’, ‘my_remove_meta_boxes’ ); additionaly, you will have to hide #edit-slug-box with css or javascript. see: Loading External Scripts in Admin but ONLY for a Specific Post Type? … Read more