WebMuggle
Forum Replies Created
Viewing 2 replies - 1 through 2 (of 2 total)
-
Forum: Plugins
In reply to: [Multiple Featured Images] can't get to work in custom pageHi Baus
I have just got it working for my custom post type.
From my theme’s functions.php: Here is the function creating my post type – I am guessing you have that working fine:
function create_service_type() { register_post_type( 'service', array( 'labels' => array( 'name' => _x('Services', 'post type general name'), 'singular_name' => _x('Service', 'post type singular name'), 'add_new' => _x('Add New', 'book'), 'add_new_item' => __('Add New Service'), 'edit_item' => __('Edit Service'), 'new_item' => __('New Service'), 'all_items' => __('All Services'), 'view_item' => __('View Service'), 'search_items' => __('Search Services'), 'not_found' => __('No services found'), 'not_found_in_trash' => __('No services found in Trash'), 'parent_item_colon' => '', 'menu_name' => __('Services') ), 'public' => true, 'has_archive' => false, 'supports' => array( 'title', 'editor', 'thumbnail', 'excerpt' ), 'capability_type' => 'page', ) ); } add_action( 'init', 'create_service_type' );
Also from my theme’s functions.php: I am using multiple featured images on both my pages and my custom post type, so I set them up for each of these:
if( class_exists( 'kdMultipleFeaturedImages' ) ) { $args1 = array( 'id' => 'title-image', 'post_type' => 'page', // Set this to post or page 'labels' => array( 'name' => 'Title Image', 'set' => 'Set title image', 'remove' => 'Remove title image', 'use' => 'Use as title image', ) ); new kdMultipleFeaturedImages( $args1 ); } if( class_exists( 'kdMultipleFeaturedImages' ) ) { $args2 = array( 'id' => 'services-title-image', 'post_type' => 'service', // Set this to post or page 'labels' => array( 'name' => 'Title Image', 'set' => 'Set title image', 'remove' => 'Remove title image', 'use' => 'Use as title image', ) ); new kdMultipleFeaturedImages( $args2 ); }
Again in my functions.php, I have set an image size for these (you don’t have to do this, you can just use a standard wordpress image size):
if ( function_exists( 'add_image_size' ) ) { add_image_size( 'title_image', 345, 125, true ); //(cropped) }
To call the featured image on my pages I use
<?php kd_mfi_the_featured_image( ‘title-image’, ‘page’, ‘title_image’ ); ?>
An on my services post types:
<?php kd_mfi_the_featured_image( ‘services-title-image’, ‘service’, ‘title_image’ ); ?>
Hope that helps.
Forum: Plugins
In reply to: [Multiple Featured Images] Not working on custom post typesIgnore, was me being a muppet.
Viewing 2 replies - 1 through 2 (of 2 total)