Community Forums › Forums › Archived Forums › Design Tips and Tricks › Add featured image support to custom post type in Executive Pro
- This topic has 7 replies, 3 voices, and was last updated 9 years, 7 months ago by seezee.
-
AuthorPosts
-
August 8, 2014 at 9:30 am #117771seezeeMember
I'm customizing the Executive Pro child-theme for a client, and I've
created a custom post-type. I've made a plugin to extend
the custom theme (rather than using functions.php), having this line of
code:'supports' => array( 'title', 'editor', 'excerpt', 'author', 'thumbnail', 'custom-fields', 'revisions', 'genesis-cpt-archives-settings' ),
However, the featured image meta doesn't show up in
the list of available items for the post-type under screen options. The
post type does grab a thumbnail in the archive page, but it's a random (?)
pick from the uploaded images attached to the page -- I have no control
over which one it uses.I'm working with a COPY of Executive, renamed as a custom
Genesis child theme, since I needed to place a custom.css in the directory and also
needed to be able to edit the functions.php and didn't want theme updates
to overwrite my changes.I've tried this code, alternatively, in both functions.php and in my plugin, with no joy:
add_theme_support( 'post-thumbnails', array( 'page', 'post', 'cm_product' ) );
as well as the simpler
add_theme_support( 'post-thumbnails' );
I could sure use some help with this; thanks.
August 8, 2014 at 2:37 pm #117816SummerMemberI have a site with CPTs I created with the CPT UI plugin, and the Featured Image meta shows up in there just fine. I even checked the code to see what it used to create the CPT and have 'thumbnail' in 'supports' is correct.
What does the full code for your CPT look like?
Also, any child theme updates that StudioPress would make to Executive Pro would not be automatically pushed out, so that's not something you'd have to worry about.
WordPress / Genesis Site Design & Troubleshooting: A Touch of Summer | @SummerWebDesign
Slice of SciFi | Writers, After DarkAugust 11, 2014 at 9:14 am #118193seezeeMemberHere's the relevant portion of the code (the plugin has other stuff related to the site that I'm omitting here):
// Register Custom Post Type function cm_product_post_type() { $labels = array( 'name' => _x( 'Products', 'Post Type General Name', 'text_domain' ), 'singular_name' => _x( 'Product', 'Post Type Singular Name', 'text_domain' ), 'menu_name' => __( 'Product', 'text_domain' ), 'parent_item_colon' => __( 'Parent Product:', 'text_domain' ), 'all_items' => __( 'All Products', 'text_domain' ), 'view_item' => __( 'View Product', 'text_domain' ), 'add_new_item' => __( 'Add New Product', 'text_domain' ), 'add_new' => __( 'New Product', 'text_domain' ), 'edit_item' => __( 'Edit Product', 'text_domain' ), 'update_item' => __( 'Update Product', 'text_domain' ), 'search_items' => __( 'Search products', 'text_domain' ), 'not_found' => __( 'No products found', 'text_domain' ), 'not_found_in_trash' => __( 'No products found in Trash', 'text_domain' ), ); $args = array( 'label' => __( 'product', 'text_domain' ), 'description' => __( 'Product information pages', 'text_domain' ), 'labels' => $labels, 'rewrite' => array('slug' => 'products'), 'supports' => array( 'title', 'editor', 'excerpt', 'author', 'thumbnail', 'custom-fields', 'revisions', 'genesis-cpt-archives-settings' ), 'taxonomies' => array( 'category', 'post_tag' ), 'hierarchical' => false, 'public' => true, 'show_ui' => true, 'show_in_menu' => true, 'show_in_nav_menus' => true, 'show_in_admin_bar' => true, 'menu_icon' => '', 'menu_position' => 5, 'can_export' => true, 'has_archive' => true, 'exclude_from_search' => false, 'publicly_queryable' => true, 'capability_type' => 'page', ); register_post_type( 'cm_product', $args ); } // Hook into the 'init' action add_action( 'init', 'cm_product_post_type', 0 ); // Customize the Admin Menu (add icons for product post type menu) function add_menu_icons_styles(){ ?> <style> #adminmenu .menu-icon-cm_product div.wp-menu-image:before { content: "\f312"; } </style> <?php } add_action( 'admin_head', 'add_menu_icons_styles' ); /** * * Add featured image thumbnail to posts and pages * */ // Add new image size add_image_size( 'singular', 680, 510, TRUE ); add_action ( 'genesis_entry_header', 'cm_featured_image_title_singular' ); function cm_featured_image_title_singular() { if ( !is_singular() || !has_post_thumbnail() ) return; echo '<div class="singular-thumbnail">'; genesis_image( array( 'size' => 'singular' ) ); echo '</div>'; }
True that the auto-update wouldn't overwrite changes, but I'm going to be doing several sites for the client all based on Ex. Pro, so each needs its own child theme.
August 29, 2014 at 4:27 pm #121753seezeeMemberAnyone ever figure this out?
August 29, 2014 at 11:04 pm #121786SummerMemberI don't see anything that sticks out as being incorrect. Have you tried putting the code to register the post type in functions.php, just to test out if the code works as expected there? Maybe there's something off about how your plugin is trying to set things up?
Executive Pro shouldn't need the add_theme_support calls, since it already supports them (at least my copy did, out of the box).
WordPress / Genesis Site Design & Troubleshooting: A Touch of Summer | @SummerWebDesign
Slice of SciFi | Writers, After DarkAugust 30, 2014 at 1:09 am #121795Brad DaltonParticipantCheck this line
'supports' => array( 'title', 'editor', 'author', 'thumbnail', 'genesis-cpt-archives-settings' ),
August 30, 2014 at 8:35 am #121864seezeeMemberHave you tried putting the code to register the post type in functions.php, just to test out if the code works as expected there? Maybe there’s something off about how your plugin is trying to set things up?
Not yet. I'll give it a go & report back the results.
September 24, 2014 at 9:53 am #125547seezeeMemberWeird discovery — if I log out as Network Admin and log back in as a regular Admin, the featured image meta is available.
-
AuthorPosts
- The forum ‘Design Tips and Tricks’ is closed to new topics and replies.