Message on Custom Posts Type admin page

Good question. I’ve often wondered it myself. This will work. You just need to change my_post_type_slug to the slug of your post type. There might be a cleaner way to find the post type other than using $_GET but it’s good enough for now! add_action(‘all_admin_notices’, ‘my_admin_notices’); function my_admin_notices() { if ($_GET[‘post_type’] == ‘my_post_type_slug’ ) { … Read more

Post Via Email to a Custom Post Type

When a post is submitted by email and published WordPress Runs an action hook named ‘publish_phone’ so you can get the post there and change its type like this: add_action(‘publish_phone’,’custom_type_by_mail’); function custom_type_by_mail($post_id){ $p = get_post($post_id,’ARRAY_A’); $p[‘post_type’] = “YOUR_CUSTOM_TYPE_NAME_HERE”; wp_update_post($p); } Probably not the smartest way but it does work and its simple.

Limit upload by file type only for certain custom post type

function wpse_59621_mimes_filter( $mimes ) { return array( ‘pdf’ => ‘application/pdf’ ); } function wpse_59621_delay_mimes_filter( $value ) { if ( isset( $_REQUEST[‘post_id’] ) && get_post_type( $_REQUEST[‘post_id’] ) === ‘my_post_type’ ) add_filter( ‘upload_mimes’, ‘wpse_59621_mimes_filter’ ); else remove_filter( ‘upload_mimes’, ‘wpse_59621_mimes_filter’ ); return $value; } add_filter( ‘wp_handle_upload_prefilter’, ‘wpse_59621_delay_mimes_filter’ ); Let us know how it goes – this is untested, … Read more

Using shortcodes to parse POST request (containing the data from a front-end form)

Alway send submissions to the page the form is displayed. In your shortcode callback you can then display proper error or success messages. Sample: add_shortcode( ‘classifiedsform’, ‘classifiedsform_callback’ ); function classifiedsform_callback() { if ( ‘POST’ !== $_SERVER[‘REQUEST_METHOD’] or ! isset ( $_POST[‘classifieds’] ) ) { return classifieds_input_form(); } // process input show errors or success message … Read more

Query for posts in 2 taxonomies

According to the Codex, here’s how you would query posts from several taxonomies: ‘tax_query’ => array( ‘relation’ => ‘AND’, array( ‘taxonomy’ => ‘videoscategory’, ‘field’ => ‘slug’, ‘terms’ => $custom_term->slug ), array( ‘taxonomy’ => ‘yourothertaxonomy’, ‘field’ => ‘slug’, ‘terms’ => $other_custom_term->slug ) )

Custom Post Type Meta Boxes

Change advanced to normal, this will at least move it up above some others. However, there’s no guarantee you get the top spot, because a user can still drag and drop metaboxes around, or a core metabox or one added by another plugin might believe it is more important than yours. There’s no way for … Read more

How to display Custom Taxonomy of Custom post type

you can get terms in single post type template by using wp_get_post_terms(); inside loop <?php $terms = wp_get_post_terms($post->ID, ‘music’); if ($terms) { $out = array(); foreach ($terms as $term) { $out[] = ‘<a class=”‘ .$term->slug .'” href=”‘ .get_term_link( $term->slug, ‘music’) .'”>’ .$term->name .'</a>’; } echo join( ‘, ‘, $out ); } ?>