WordPress.org

Ready to get started?Download WordPress

Forums

Custom Fields and Child Pages (1 post)

  1. Mark
    Member
    Posted 3 years ago #

    I currently am using the Custom Fields and NextGen Gallery. I have the below snippet of code that pulls in the Gallery Number IF ONE EXISTS but for whatever reason it's not working for Child pages if a Gallery doesn't exist. Any ideas?

    <?php If ( $gallery = get_post_meta($post->ID, 'gallery', true)) {
    
        $gal = $gallery;
        $gal = apply_filters('the_content', '<div id="maintop">' .'[nggallery id=' .$gal.']</div>' );
        echo $gal;
    
    } else {
        echo "";
    }

    It's working out awesome for the Parent Pages and those that actually have a gallery assigned to it, but not for Child pages that DON"T have a gallery.

    What am I doing wrong??

Topic Closed

This topic has been closed to new replies.

About this Topic