ID, 'gallery_post', True); if ($gallery_post > 0) { $gallery_post_content = do_shortcode('[gallery id="'. $gallery_post .'" captiontag="" itemtag="div" icontag="span" ]'); $content .= '
' . $gallery_post_content . '
'; } return $content; } function gallery_post_custom_box() { add_meta_box("gallery-post", __("Gallery Post", "gallery_post"), "gallery_post_innerbox_html", "post", "advanced"); } function gallery_post_innerbox_html() { global $post, $wpdb; // Use nonce for verification wp_nonce_field( plugin_basename(__FILE__), 'gallery_post_noncename' ); // get current gallery post $gallery_post = get_post_meta($post->ID, 'gallery_post', True); // get id's of current gallery posts $sql = "SELECT meta_value FROM $wpdb->postmeta WHERE meta_key='gallery_post'"; if ($gallery_post != "") { $sql .= " AND meta_value <> $gallery_post"; } $existing_gallery_posts = $wpdb->get_results($sql); $exclude = ""; foreach ($existing_gallery_posts as $existing) { $exclude .= $existing->meta_value . ","; } $exclude = trim($exclude, ','); // The actual fields for data entry $category = get_category(get_option('gallery_post_category')); echo "

Gallery Category: " . $category->name . "

"; $posts = get_posts(array('numberposts' => -1, 'category' => $category->term_id, 'exclude' => $exclude)); $upload_dir = wp_upload_dir(); $plugin_url = GALLERY_POST_URL . 'gallery-post-show.php'; echo '

Select the gallery to attach to the post: '; echo '

'; echo '
'; ?> 1) { // save the post data update_post_meta($post_id, 'gallery_post', $gallery_post); // update the thumbnail id $thumbnail_id = get_post_thumbnail_id($gallery_post); update_post_meta( $post_id, '_thumbnail_id', $thumbnail_id ); } else { // remove post meta data $gp = get_post_meta($post_id, 'gallery_post', True); if ($gp) { delete_post_meta($post_id, 'gallery_post'); delete_post_meta($post_id, '_thumbnail_id'); } } return $gallery_post; } function gallery_post_settings_page() { global $wpdb; ?>

Gallery Post Options

This is the category that empty gallery posts are stored in.

Gallery Category 0, 'name' => 'gallery_post_category', 'orderby' => 'name', 'selected' => get_option('gallery_post_category'), 'hierarchical' => true, 'show_option_none' => __('None'))); ?>

Gallery Post Reports

+ Posts with no gallery or featured image

posts . " l, " . $wpdb->users . " u WHERE l.post_author=u.ID AND l.ID NOT IN (SELECT DISTINCT post_id FROM " . $wpdb->postmeta ." l WHERE meta_key = '_thumbnail_id' OR meta_key='gallery_post') AND l.ID NOT IN (SELECT object_id FROM " . $wpdb->term_relationships . " l WHERE l.term_taxonomy_id = " . $gallery_post_category . ") AND l.post_status='publish' and l.post_type='post' ORDER BY l.post_date DESC"; #print $sql; $results = $wpdb->get_results($sql); print ''; print ''; if ($results) { foreach ($results as $result) { print ''; print edit_post_link($result->post_title, '', $result->ID); print ''; print ''; print ''; print ''; } } else { print ''; } ?>
TitleAuthorStatusDate
', '' . $result->display_name . '' . $result->post_status . '' . $result->post_date . '
None found.

+ Unattached Gallery Posts

term_relationships . " l, ". $wpdb->posts . " p, " . $wpdb->users . " u WHERE p.post_author=u.ID AND l.object_id = p.ID AND l.object_id NOT IN (SELECT l.object_id FROM " . $wpdb->term_relationships . " l, " . $wpdb->postmeta . " p WHERE l.term_taxonomy_id = 61 and p.meta_key = 'gallery_post' and p.meta_value=l.object_id) AND l.term_taxonomy_id=61"; $results = $wpdb->get_results($sql); print ''; print ''; if ($results) { foreach ($results as $result) { print ''; print edit_post_link($result->post_title, '', $result->object_id); print ''; print ''; print ''; print ''; } } else { print ''; } ?>
TitleAuthorStatusDate
', '' . $result->display_name . '' . $result->post_status . '' . $result->post_date . '
None found.

+ Gallery Posts w/o Featured Image

term_relationships . " l, ". $wpdb->posts . " p, ". $wpdb->users . " u WHERE p.post_author = u.ID AND l.object_id = p.ID AND l.object_id NOT IN (SELECT l.object_id FROM " . $wpdb->term_relationships . " l, " . $wpdb->postmeta . " p WHERE l.term_taxonomy_id = 61 and p.meta_key = '_thumbnail_id' and p.post_id=l.object_id) AND l.term_taxonomy_id=61"; $results = $wpdb->get_results($sql); print ''; print ''; if ($results) { foreach ($results as $result) { print ''; print edit_post_link($result->post_title, '', $result->object_id); print ''; print ''; print ''; print ''; } } else { print ''; } ?>
TitleAuthorStatusDate
', '' . $result->display_name . '' . $result->post_status . '' . $result->post_date . '
None found.