Automatically Set Featured Image on Create New Page
-
Hi there,
I’m working on a client site and would like for some things to be a bit more automated for them if possible. Right now, if you’ve just created a new gallery, you have the option of Create New Page in the gallery settings where pressing the Add Page button will create a new page with a shortcode to that gallery. Then it’s up to the user to go to that new page and select an image to be the featured image.
The code that makes this happen in Nextgen appears to be in \admin\manage.php:
// Add a new page check_admin_referer('ngg_updategallery'); $parent_id = esc_attr($_POST['parent_id']); $gallery_title = esc_attr($_POST['title']); $gallery_name = $wpdb->get_var("SELECT name FROM $wpdb->nggallery WHERE gid = '$this->gid' "); // Create a WP page global $user_ID; $page['post_type'] = 'page'; $page['post_content'] = '[nggallery id=' . $this->gid . ']'; $page['post_parent'] = $parent_id; $page['post_author'] = $user_ID; $page['post_status'] = 'publish'; $page['post_title'] = $gallery_title == '' ? $gallery_name : $gallery_title; $page = apply_filters('ngg_add_new_page', $page, $this->gid); $gallery_pageid = wp_insert_post ($page); if ($gallery_pageid != 0) { $result = $wpdb->query("UPDATE $wpdb->nggallery SET title= '$gallery_title', pageid = '$gallery_pageid' WHERE gid = '$this->gid'"); p_cache_delete($this->gid, 'ngg_gallery'); nggGallery::show_message( __('New gallery page ID','nggallery'). ' ' . $gallery_pageid . ' -> <strong>' . $gallery_title . '</strong> ' .__('created','nggallery') ); } do_action('ngg_gallery_addnewpage', $this->gid); }
Could anyone give me some insights on how to have this function automatically use the selected “Preview Image” from the particular gallery settings page become the default featured image of the newly created page?
Thanks much!
https://www.ads-software.com/extend/plugins/nextgen-gallery/
- The topic ‘Automatically Set Featured Image on Create New Page’ is closed to new replies.