Using a Custom Field instead of original title field but only for Custom Post Type

The solution you are working on will always represent multiple database inserts as the post will be saved and then the the title re-saved in a second database write. That is the nature of the save_post hook, since it runs after the primary post save. Additionally, the code you found is wildly overcomplicated. Interestingly, the … Read more

Website bookmarks as a custom post type

Here’s a clean way to accomplish what you need. Register custom post types (sans post_tags and categories) Register taxonomies specific to your bookmarks Create a post meta box for the bookmark options (sample included). You could add a nofollow checkbox option to the meta box. Save post meta Here’s the whole shabang. add_action(‘init’, ‘bookmark_post_type’); function … Read more

action init hook and get_post_types

Because you calling get_post_types() in functions.php that is excuted before ‘init’ action. Look this picture http://www.rarst.net/images/wordpress_core_load.png if you add an echo inside function test function test(){ $args = array( ‘public’ => true, ‘publicly_queryable’ => true, ‘show_ui’ => true, ‘query_var’ => true, ‘exclude_from_search’ => true, ‘hierarchical’ => false, ‘has_archive’ => false, ); register_post_type( ‘test’, $args ); … Read more

How to save the checked boxes?

You can use PHP in your functions.php file to insert inline JavaScript (including jQuery) using WordPress hooks. In your example, you could use the admin_print_scripts-post.php action hook to print your inline jQuery like so: function wpse_admin_print_scripts_edit() { echo “<script>var limit = 2;’ . ‘jQuery(‘input.single-checkbox’).on(‘change’, function(evt) {‘ . ‘if(jQuery(‘input.single-checkbox:checked’).length > limit) {‘ . ‘this.checked = false;’ … Read more

wp_list_categories and custom post types

By default, category archives only show posts of the default ‘post’ type. The below code should get it working how you want. —via CSS Tricks function namespace_add_custom_types( $query ) { if( is_category() || is_tag() && empty( $query->query_vars[‘suppress_filters’] ) ) { $query->set( ‘post_type’, array( ‘post’, ‘your-custom-post-type-here’ )); return $query; } } add_filter( ‘pre_get_posts’, ‘namespace_add_custom_types’ );

How to Change the Title of a Meta Box on a Specified Custom Post Type? [duplicate]

Yes – you need a slightly modified version of this answer. add_action( ‘add_meta_boxes_post’, ‘wpse39446_add_meta_boxes’ ); function wpse39446_add_meta_boxes( $post ) { if( ‘mycpt’ == get_post_type($post) ){ remove_meta_box( ‘authordiv’, ‘mycpt’, ‘core’ ); add_meta_box( ‘authordiv’, __(‘Team Member’,’wpse39446_domain’), ‘post_author_meta_box’, ‘mycpt’, ‘advanced’, ‘high’ ); } } Note: If you are doing this for a non-core metabox, you’ll need to ensure … Read more

Custom Taxonomy List links being re-written

After taking @Milo ‘s comments into consideration, I removed the s= argument from the link, and it worked! This is my final code: function job_listing_taxonomy_list( $taxonomy,$hide ) { $args = array(‘order’=>’ASC’,’hide_empty’=>$hide); $terms = get_terms( $taxonomy, $args ); if ( $terms ) { printf( ‘<ul name=”%s”>’, esc_attr( $taxonomy ) ); foreach ( $terms as $term ) … Read more

How to print all posts of a given post-type (CPT) in a given webpage?

You could use get_posts() to get posts of a particular type, then use a for loop to print out links, titles, etc as required. Maybe put this in a custom template for your “All book pages” page. More info on templates here. Example: $posts = get_posts(array( “post_type”=>”book_pages”, “post_status”=>”publish”, “posts_per_page”=>-1 )); if ($posts && count($posts)>0) { … Read more