WordPress.org

Ready to get started?Download WordPress

Forums

Multiple Featured Images
Doesn't work on pages. (4 posts)

  1. Astraldiva
    Member
    Posted 1 year ago #

    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/

  2. Nathan Parikh
    Member
    Posted 1 year ago #

    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 );
    }
  3. Andrew Tegenkamp
    Member
    Posted 1 year ago #

    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 :)

  4. Nathan Parikh
    Member
    Posted 1 year ago #

    Glad it helped, Andrew!

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.