How to customize the Categories meta box to allow only one category?

Freed from comment; the asker really did not want to write an answer. :/ function convert_root_cats_to_radio() { global $post_type; ?> <script type=”text/javascript”> jQuery(“#activitycategorychecklist>li>label input”).each(function(){ this.disabled = “disabled”; }); jQuery(“#activitycategorychecklist>li>ul>li>label input”).each(function(){ this.type=”radio”; }); jQuery(“#activitycategory-tabs li:odd”).hide(); </script> <?php } add_action( ‘admin_footer-post.php’, ‘convert_root_cats_to_radio’ ); add_action( ‘admin_footer-post-new.php’, ‘convert_root_cats_to_radio’ );

List all custom post type posts from a given category?

What about doing a tax_query? $args = array( ‘post_type’ => ‘myposttype’, ‘tax_query’=> array(         ‘taxonomy’ => ‘myposttype_categories’,         ‘terms’ => array(‘foo’),         ‘field’ => ‘slug’,     ) ); $loop = new WP_Query( $args ); var_dump($loop); Facepalm question, you are sure that these taxonomies/post types exist and that there are posts filed under them? Update The query seems to work … Read more

Only Show an Author Their Custom Post Types

As @s_ha_dum says in his comment, your description and your code seems to be different. If I understand the description, the code to do what you want is: function __set_all_posts_for_author( $query ) { if ( is_admin() && is_post_type_archive( array(‘listings’, ‘contacts’, ‘events’) ) ) { $current_user = wp_get_current_user(); $query->set( ‘author’, $current_user->ID ); } } add_action( ‘pre_get_posts’, … Read more

Excluding post type from WordPress link builder

Versions <= 3.6.1 It looks like the function wp_link_query() is used to display the internal posts/pages when you press the Or link to existing content in the “link builder”: wp_link_query() is defined in /wp-includes/class-wp-editor.php. It is queried via the wp_ajax_wp_link_ajax(), defined in the file /wp-admin/includes/ajax-actions.php. These functions don’t have any explicit filters to change the … Read more

exclude custom post type by meta key in wp_query

If you don’t use any other meta data, just add the following to your $args: ‘meta_key’ => ‘sold’, ‘meta_value’ => true, // or whatever it is you’re using here ‘meta_compare’ => ‘!=’, Otherwise, use a WP_Meta_Query: ‘meta_query’ => array( array( ‘key’ => ‘sold’, ‘value’ => true, // or whatever it is you’re using here ‘compare’ … Read more

Custom field losing p tags on display

Add this to your functions.php file: add_filter( ‘meta_content’, ‘wptexturize’ ); add_filter( ‘meta_content’, ‘convert_smilies’ ); add_filter( ‘meta_content’, ‘convert_chars’ ); add_filter( ‘meta_content’, ‘wpautop’ ); add_filter( ‘meta_content’, ‘shortcode_unautop’ ); add_filter( ‘meta_content’, ‘prepend_attachment’ ); Then use this code to pull in the result: <?php $story_content = get_post_meta($post->ID, ‘story’, true); echo apply_filters(‘meta_content’, $story_content); ?>

Adding help information to custom post edit page

Try this: function options_instructions_example() { global $my_admin_page; $screen = get_current_screen(); if ( is_admin() && ($screen->id == ‘custom_post_type_name’) ) { function add_content_after_editor() { global $post; $id = $post->ID; echo ‘<div class=”postbox” style=”background:#0074a2;color:#fff;margin-top:20px;”><div class=”inside”>’; echo ‘Instructions go here.’; echo ‘</div></div>’; } add_action( ‘edit_form_after_title’, ‘add_content_after_editor’ ); } } add_action( ‘admin_notices’, ‘options_instructions_example’ ); It will result in something that … Read more

How to add post_author column to custom post type

The $supports argument should include author for the Author settings to be available for the custom post type: ‘supports’ => array( ‘title’, ‘custom-fields’, ‘author’ ) ‘supports’ (array) Core feature(s) the post type supports. Serves as an alias for calling add_post_type_support() directly. Core features include ‘title’, ‘editor’, ‘comments’, ‘revisions’, ‘trackbacks’, ‘author’, ‘excerpt’, ‘page-attributes’, ‘thumbnail’, ‘custom-fields’, and … Read more