kaxe
Forum Replies Created
-
Hi Bradvin,
Sure!
here is the code:
At attachment.php (create one if the file does not exist)
<?php your_custom_function(); ?>
and then, at functions.php of your theme:
add_action ('foogallery_init', 'your_custom_function'); function your_custom_function(){ if (is_attachment()) { global $wp; global $post; // some attachment page are /?attachment_id=123. get it directly $this_post_id = $post->ID; // Some attachment page URL is with Slug. $post->ID is blank. Get the Post ID from slug. //https://wordpress.stackexchange.com/questions/210639/how-to-get-custom-post-type-post-id-from-slug //https://wordpress.stackexchange.com/questions/274569/how-to-get-url-of-current-page-displayed //https://wordpress.stackexchange.com/questions/42117/how-to-retrieve-the-slug-of-current-page $current_url = home_url($wp->request); $current_slug = $post->post_name; if (empty($_GET) && strpos($current_url, $current_slug) !== FALSE) { $this_post = get_page_by_path($current_slug, OBJECT, 'post_type'); $this_post_id = $this_post->ID; } // Find the FooGallery ID containing this image. $foogallery_id = wp_get_post_parent_id( $this_post_id ); // Using the foogallery ID as key to find the published post with this foogallery. $args = array( 'post_type' => 'post', 'post_status' => 'publish', 'meta_key' => '_foogallery', 'meta_value' => $foogallery_id ); $my_query = new WP_Query( $args ); if ($my_query->have_posts()) { //https://wordpress.stackexchange.com/questions/124642/is-get-posts-more-efficient-than-the-loop $x = 0; foreach ($my_query->posts as $p) { $permalink = get_the_permalink($p->ID); // If more than one published post is found, clicking on the attachment image will go to the first. if ($x == 0) { $output = array('<a href="' . $permalink .'">', wp_get_attachment_image(get_the_ID(), 'full'), '</a>' ); echo join($output); } $featured_img = wp_get_attachment_image_src( get_post_thumbnail_id( $p->ID ), 'single-post-medium' ); $output = array('<div class="post_img">', '<a href="' . $permalink . '">', '<img src=' . $featured_img[0] . ' alt="' . get_the_title($p->ID) . '">', '</a>', '</div>' ); echo join($output); $x++; } } else { // Something occured. FooGallery ID not found. maybe image is not attached to the foogallery. // Still display a normal image as a failsafe. $output = array('<a href="' . home_url() .'">', wp_get_attachment_image(get_the_ID(), 'full'), '</a>' ); echo join($output); } } }
- This reply was modified 6 years, 2 months ago by kaxe.
Hi,
I have resolved it by using the standard WP_Query method. thank you!
Nevermind! I will see if the updates of the plugin fix that minor thing. Thank you!
@duongcuong96 Both 20seconds execution time (was 30 secs) & No backup file compression do not help.
Same error still exist but the backup file is successfully created and sent to dropbox
??I have just set it to 5 (it was 3) and manually run the job. The error now occurs at the 5th attempt, and the file is transferred to Dropbox successfully. The zip file is normal too.
Oh, while the LOG says 18MB (7 files), the actual file is just 3.6MB (3 files, readme.txt/manifest.json/the Gzipped sql)
[INFO] BackWPup 3.6.0; A project of Inpsyde GmbH [INFO] WordPress 4.9.7 on https://URL/ [INFO] Log Level: Normal [INFO] BackWPup job: Daily Backup [INFO] Logfile is: backwpup_log_dd2a37_2018-08-02_15-17-45.html [INFO] Backup file is: backwpup_WHOSUNYC01_154a9b6_dd2a37_2018-08-02_15-17-45.zip [02-Aug-2018 15:17:45] 1. Try to backup database … [02-Aug-2018 15:17:45] Connected to database XXX on localhost [02-Aug-2018 15:17:50] Added database dump "XXX.sql.gz" with 3.65 MB to backup file list [02-Aug-2018 15:17:50] Database backup done! [02-Aug-2018 15:17:51] 2. Try to backup database … [02-Aug-2018 15:17:51] Connected to database XXX on localhost [02-Aug-2018 15:17:51] Added database dump "XXX.sql.gz" with 3.65 MB to backup file list [02-Aug-2018 15:17:51] Database backup done! [02-Aug-2018 15:17:51] 3. Try to backup database … [02-Aug-2018 15:17:51] Connected to database XXX on localhost [02-Aug-2018 15:17:51] Added database dump "XXX.sql.gz" with 3.65 MB to backup file list [02-Aug-2018 15:17:51] Database backup done! [02-Aug-2018 15:17:51] 4. Try to backup database … [02-Aug-2018 15:17:51] Connected to database XXX on localhost [02-Aug-2018 15:17:51] Added database dump "XXX.sql.gz" with 3.65 MB to backup file list [02-Aug-2018 15:17:51] Database backup done! [02-Aug-2018 15:17:51] 5. Try to backup database … [02-Aug-2018 15:17:51] Connected to database XXX on localhost [02-Aug-2018 15:17:51] Added database dump "XXX.sql.gz" with 3.65 MB to backup file list [02-Aug-2018 15:17:51] Database backup done! [02-Aug-2018 15:17:51] ERROR: Step aborted: too many attempts! [02-Aug-2018 15:17:51] 1. Trying to generate a manifest file … [02-Aug-2018 15:17:51] Added manifest.json file with 8.78 KB to backup file list. [02-Aug-2018 15:17:52] 1. Trying to create backup archive … [02-Aug-2018 15:17:52] Compressing files as ZipArchive. Please be patient, this may take a moment. [02-Aug-2018 15:17:52] Backup archive created. [02-Aug-2018 15:17:52] Archive size is 3.65 MB. [02-Aug-2018 15:17:52] 7 Files with 18.28 MB in Archive. [02-Aug-2018 15:17:53] 1. Try to send backup file to Dropbox … [02-Aug-2018 15:17:53] Authenticated with Dropbox of user: XXX [02-Aug-2018 15:17:53] Uploading to Dropbox … [02-Aug-2018 15:17:55] Backup transferred to /XXX/backwpup_WHOSUNYC01_154a9b6_dd2a37_2018-08-02_15-17-45.zip [02-Aug-2018 15:17:56] One file deleted from Dropbox [02-Aug-2018 15:17:56] One old log deleted [02-Aug-2018 15:17:56] ERROR: Job has ended with errors in 11 seconds. You must resolve the errors for correct execution.
- This reply was modified 6 years, 3 months ago by kaxe. Reason: add more information
Yes. I can find it from my Dropbox account. The Zip file was a successful archive that can be opened. the SQL is there.
So the problem is: it is a successful backup task for BackWpUp but there are ERROR in logs..