ruess
Forum Replies Created
-
No worries quirkylissy.
I can’t help you with the “retrospectively” part, but if you want this to work for creating new posts instead of pages from inside a NextGEN gallery, find the code (also in manage.php):
// Create a WP page global $user_ID; $page['post_type'] = 'page';
and change the post type from “page to “post”:
$page['post_type'] = 'post';
Maybe that will help a bit ??
Also, switch to twenty-eleven or twenty-twelve theme temporarily to see if that affects your outcome ??
Hmm. not sure if it helps, but please note that this code will only work when adding a new page FROM a NextGEN gallery – it will not work when inserting a NextGEN gallery into a page.
Thus, make sure you’re going from the Dashboard to:
Gallery->Manage Gallery->[Choose a gallery]->Create new page (button located at upper right)Hmm. . so one question to see whether the code is functioning at all would be to see if the preview image is appearing in the media gallery after you click the Add Page from the NextGen gallery you’re in. Also, see if you can check the uploads folder to see if any new images have been copied there. If nothing is going on, then there’s something wrong with the code itself or the placement of the code.
Thanks,
kevion
Hey Quirklissy,
The original file has the following lines:
$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'"); wp_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); } --> enter my code above right here }
Let me know if that works for you or if you’re still having trouble. Also, just to be save, please include the version of NextGen you’re using.
OK, so I have found a solution for this after much toil ??
Add the following to \nextgen-gallery\admin\manage.php right after the following code:
do_action('ngg_gallery_addnewpage', $this->gid); }
and before the “}” immediately following:
//Start Set Featured Image //Determine filepath of selected NextGEN preview image $gallery_id = $this->gid; // Use the PODS column, custom post field or however you would get this ID $results = $wpdb->get_results("SELECT ng.path, np.filename FROM wp_ngg_pictures np, wp_ngg_gallery ng WHERE np.galleryid=ng.gid AND np.galleryid=".$gallery_id." AND np.pid=ng.previewpic",ARRAY_A); if(!empty($results[0]['path']) && !empty($results[0]['filename'])) : $imgpath = ABSPATH.$results[0]['path'].'/'.$results[0]['filename']; endif; //Set filepath and filename variables $image_url = $imgpath; //Copy the file from the NextGen Gallery to the Media Library (uploads folder) $upload_dir = wp_upload_dir(); $filename = basename($image_url); if(wp_mkdir_p($upload_dir['path'])) $file = $upload_dir['path'] . '/' . $filename; else $file = $upload_dir['basedir'] . '/' . $filename; //Perform copy function if (!copy($imgpath, $file)) { echo "failed to copy $file...\n"; } //Create entry in media library $wp_filetype = wp_check_filetype($filename, null ); $attachment = array( 'post_mime_type' => $wp_filetype['type'], 'post_title' => sanitize_file_name($filename), 'post_content' => '', 'post_status' => 'inherit' ); $attach_id = wp_insert_attachment( $attachment, $file, $post_id ); //Set featured image for newly created page set_post_thumbnail($gallery_pageid, $attach_id); //End Set Featured Image
What this code does is to grab the file location of the selected preview image from the particular NextGen gallery you’re on, copies that image into the media library, creates a media library database entry for the file, and finally updates the featured image on the new page with the ID of that image.
Hope this helps!
kevin
Well sorta works – now I can’t filter it by category though – only able to display the entire lot of my custom post type. ??
Cool anicode – let me know if you discover anything – and will as well.
Forum: Hacks
In reply to: Sending 2 duplicate emails when custom post publishedVery roughly, with this definition in mind:
set_transient( $transient, $value, $expiration );
would it be something to the effect of:
set_transient( [my function above], $my-email-message, $expiration );
? Hmm. .that doesn’t seem to make much sense does it? (scratching head)
Forum: Hacks
In reply to: Sending 2 duplicate emails when custom post publishedThanks bcworkz – that sounds plausible – yet complicated ?? If anyone has any guidance on how to structure this that would be very helpful – not even sure where to start.
Thanks!
kevin
woops “add the *line*” not “link” ??
I think I got it.
In file: CatGridData.php, find:
//Build the query for get_posts() $cgquery = array( 'cat' => $this->cgid , 'posts_per_page' => $this->params['num'] , 'orderby' => $this->params['orderby'] , 'order' => $this->params['order'] , 'post__not_in' => explode(',',$this->params['excludeposts']) , 'tag' => $this->params['tags'] , 'offset' => $this->params['offset'], 'meta_key' => $this->params['customfield'], 'meta_value' => $this->params['customfieldvalue'], );
then add the link:
'post_type' => array('post','custom_post_type')
right after:
'meta_value' => $this->params['customfieldvalue'],
and before
);