• Resolved WebMuggle

    (@webmuggle)


    I am having problems using this on a custom post type.

    Here is the function that creates my custom post type:

    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' );

    That works fine

    And then here is the code for both of the additional featured images that I have set up.

    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 );
    }

    I have an image size set for them:

    if ( function_exists( 'add_image_size' ) ) {
    	add_image_size( 'title_image', 345, 125, true ); //(cropped)
    }

    And then, when calling the image on a page type it works fine. That’s the code I use for that:

    <?php kd_mfi_the_featured_image( 'title-image', 'page', 'title_image' ); ?>

    Now, the code that doesn’t work – this is what I have on my service custom post:

    <?php kd_mfi_the_featured_image( 'services-title-image', 'service', 'title-image' ); ?>

    Any ideas on why that doesn’t work?

    The site this is on is https://host18.qnop.net/~lisalinc/

    Pages where it works, there is an image next to the title, .e.g https://host18.qnop.net/~lisalinc/about/

    On the services pages, it doesn’t work, e.g. https://host18.qnop.net/~lisalinc/service/health-wellbeing/

    I really hope someone can help.

    https://www.ads-software.com/extend/plugins/multiple-featured-images/

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘Not working on custom post types’ is closed to new replies.