WordPress.org

Support

Support » Plugins and Hacks » Multiple Featured Images » [Plugin: Multiple Featured Images] Doesn't work on pages.

[Plugin: Multiple Featured Images] Doesn't work on pages.

  • Hello,

    using your plugin and works great on posts. But something is not working on pages or maybe I am missing something.

    I use this code to add the support to pages and on page administration the box for image appears and I can add the image there.

    $background_page_args = array(
                    'id' => 'full-background-image',
                    'post_type' => 'page',      // Set this to post or page
                    'labels' => array(
                        'name'      => 'Full Background image',
                        'set'       => 'Set Full Background image',
                        'remove'    => 'Remove Full Background image',
                        'use'       => 'Use as Full Background image',
                    )
            );

    But when I use this code to get the image in the page the function returns NULL.

    if( class_exists( 'kdMultipleFeaturedImages' ) ) {
    kd_mfi_the_featured_image( 'full-background-image', 'page', 'full' );
    }

    Also I want to note that this function is used on page-about-me.php (template for specific page).

    Appreciate your help in advance.

    http://wordpress.org/extend/plugins/multiple-featured-images/

Viewing 3 replies - 1 through 3 (of 3 total)
  • You are probably calling it outside of the loop, so it doesn’t know which post ID to reference, so it’s drawing a blank.
    This will most likely be your solution:

    global $wp_query;
    $thePostID = $wp_query->post->ID;
    
    if( kd_mfi_get_featured_image_url( 'full-background-image', 'page', 'full', $thePostID ) != "" ) {
        echo kd_mfi_get_featured_image_url( 'full-background-image', 'page', 'full', $thePostID );
    }

    Thanks Nathan, adding the parameter for the post ID works great in my application of this great plugin! I see it now at the bottom of the documentation, too 🙂

    Glad it helped, Andrew!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘[Plugin: Multiple Featured Images] Doesn't work on pages.’ is closed to new replies.
Skip to toolbar