This is the error that was logged:
[04-Oct-2022 18:31:36 UTC] PHP Fatal error: Uncaught Error: Call to a member function get_children() on bool in /home/xxxxx/public_html/wp-content/plugins/woo-variation-swatches/includes/class-woo-variation-swatches-product-page.php:170
Stack trace:
#0 /home/xxxxx/public_html/wp-includes/class-wp-hook.php(307): Woo_Variation_Swatches_Product_Page->add_to_cart_variation_params(Array, ‘wc-add-to-cart-…’)
Can you please provide a fix for this problem?
Thank you
https://www.ads-software.com/plugins/download-monitor/
]]><?php
$thumb_ID = get_post_thumbnail_id($pid);
$images =& get_children( array (
'post_parent' => $pid,
'post_status' => 'inherit',
'post_type' => 'attachment',
'post_mime_type' => 'image',
'order'=> 'ASC',
'orderby' => 'menu_order ID',
'exclude' => $thumb_ID,
));
if ( empty($images) ) {
// no attachments here
} else {
//echo '<ul>';
$iloop=0;
foreach ( $images as $attachment_id => $attachment ) {
if($iloop==7) break;
echo '<a class="fancybox" rel="group" href="'.wp_get_attachment_url( $attachment_id, 'medium' ).'">'.wp_get_attachment_image( $attachment_id, 'thumbnail').'</a>';
$iloop++;
}
}
?>
I have tried sorting by “ID’, “menu_order”, and “post__in” but it still does not put the images in the right sequence. The order does change when I add or remove the order_by clause, but it does not properly sequence it. I have looked at the postmeta that is saved where the information apparently comes from and it is just a longtext field. It does get updated when the user moves and image position here is a sample of the text
{i:0;a:6:{s:2:"id";s:5:"31605";s:3:"url";s:82:"http:/domain.staging.wpengine.com/wp-content/uploads/2016/05/IMG_9112.jpg";s:9:"thumbnail";s:90:"https://domain.staging.wpengine.com/wp-content/uploads/2016/05/IMG_9112-150x150.jpg";s:4:"name";s:8:"IMG_9112";s:7:"caption";s:0:"";s:11:"description";s:0:"";}
There are no shortcodes being used and the only thing unique about the wp_postmeta record is the meta_key which is “gallery_auction” for all the custom post types. In the record above, the only thing I can see that changes is the first part of the record {i:0;a:6:… where the “i” value gets incremented when the position changes.
Please help me find a way to do fix this issue?
]]>Hope someone can help with this. What I want is to display Post Thumbnails from a specific category in the flexslider.
I’m using the following code so far which gets all irfomation from a specific category posts, but the thumbnails does not appear as a slide.
<?php
function add_flexslider() { // display attachment images as a flexslider gallery
$attachments = get_children(array(
'numberposts' => 2,
'post_status'=>"publish",
'post_type'=>"post",
'category_name' => 'Destaque', // category slug
)
);
if ($attachments) { // see if there are images attached to posting
echo '<div class="flexslider">';
echo '<ul class="slides">';
foreach ( $attachments as $attachment_id => $attachment ) { // create the list items for images with captions
echo '<li>';
echo wp_get_attachment_image_src( get_post_thumbnail_id($attachment->ID), 'full' );
echo '<p>';
echo get_post_field('post_excerpt', $attachment->ID);
echo '</p>';
echo '</li>';
}
echo '</ul>';
echo '</div>';
} // end see if images
}
//
?>
]]>I understand that images added to a post are part of the_content() of that post but I feel there should be a way to extract them. Thanks in advance for any help.
]]>simple-image-sizes/classes/admin/media.php
(Version 3.0) have a few bugs:
1. Line 395
$attachments = get_children( array(
'post_type' => 'attachment',
'post_mime_type' => 'image',
'numberposts' => -1,
'post_status' => null,
'post_parent' => null, // any parent
'output' => 'ids',
) );
I have a couple of notes about this one, so I’ll break them down:
1a. The first parameter argument 'output' => 'ids',
does nothing. There’s a second parameter called output
but it doesn’t work that way either. So this function returns a potentially very large array of full posts.
1b. The actual sql query generated is:
SELECT wp_posts.* FROM wp_posts WHERE 1=1
AND (wp_posts.post_mime_type LIKE 'image/%')
AND wp_posts.post_type = 'attachment'
AND ((wp_posts.post_status = 'inherit'))
ORDER BY wp_posts.post_date DESC
1c. I suggest this replacement at line 395, which is similar to your other counting query:
$attachments = $wpdb->get_var( "SELECT COUNT( ID )
FROM $wpdb->posts
WHERE 1 = 1
AND post_type = 'attachment'
AND post_status = 'inherit'
$whichmimetype" );
2. Line 405
There’s a real bug here, affecting the post_types branch.
// Return the Id's and Title of medias
SIS_Admin_Main::displayJson( array( 'total' => count( $attachments ) ) );
I suggest:
// Return the Id's of medias
SIS_Admin_Main::displayJson( array( 'total' => $attachments ) );
The problem is that when the query was $attachments = get_var( "SELECT COUNT( ID )...
, then count( $attachments )
is always 1, because it’s not an array. Your code has that kind of query in the post_types branch (and my suggested code has it in the other branch).
3. Line 462
The query here has
post_status' => 'any'
and generates this sql query:
SELECT wp_posts.ID FROM wp_posts WHERE 1=1
AND (wp_posts.post_mime_type LIKE 'image/%')
AND wp_posts.post_type = 'attachment'
AND ((wp_posts.post_status <> 'trash' AND wp_posts.post_status <> 'auto-draft'))
ORDER BY wp_posts.post_date DESC LIMIT 1, 1
You can see the ‘post_status’ clause does not exactly match the above stuff in #1b, when the code was making a count. So I’d suggest for consistency at line 462:
post_status' => 'inherit'
So in summary:
1. efficiency for non-post_types branch
2. real bug for post_types branch
3. consistency for non-post_types branch
Thanks….
https://www.ads-software.com/plugins/simple-image-sizes/
]]>I have been looking high and low for a solution, and have actually found a few posts on the matter. However, none of the solutions seem to be working for me—although I do think that they have gotten me close.
The problem
I am building a template(s) that should pull all the media (images and video—but maybe let’s just start with images associated with the current post/page and output them as list items in an
function add_flexslider() { // display attachment images as a flexslider gallery
$attachments = get_children(array('post_parent' => get_the_ID(), 'order' => 'ASC', 'orderby' => 'menu_order', 'post_type' => 'attachment', 'post_mime_type' => 'image','caption' => $attachment->post_excerpt, ));
if ($attachments) { // see if there are images attached to posting ?>
<!-- Begin Slider -->
<div class="flexslider">
<ul class="slides">
<?php // create the list items for images
foreach ( $attachments as $attachment_id => $attachment ) {
echo '<li>';
echo wp_get_attachment_image($attachment_id, 'large');
echo '</li>';
} ?>
</ul>
</div>
<!-- End Slider -->
<?php } // end see if images
} // end add flexslider
Then I bring in the function like so: <?php add_flexslider(); ?>
So far this is not returning any results. I was playing around with different variations previously, and removing “post_parent’ => get_the_ID()” got it working, but it brought in ALL my images in a carousel so crazy it would make your head spin!
Additional Concerns
I am using this code for a dev. site, so all of the post/page images are actually hyperlinks to the live site. Should this make a difference? Also, all images were inserted/published right through the WordPress WYSIWYG editor, no galleries, fancy plugins, or anything else.
Thanks in advance for your consideration! Y’all are the best! ]]>
$args = array(
'numberposts' => 1,
'order'=> 'DESC',
'post_mime_type' => 'image',
'post_parent' => $post->ID,
'post_type' => 'attachment'
);
$get_children_array = get_children($args,ARRAY_A); //returns Array ( [$image_ID]...
$rekeyed_array = array_values($get_children_array);
$child_image = $rekeyed_array[0];
$TheImageID = $child_image['ID'];
$TheImageAttribs = wp_get_attachment_image_src( $TheImageID, 'full' ); // returns an array
$TheImageURL = $TheImageAttribs[0];
In most cases, $TheImageURL is the url for the full sized image. However, in SOME cases, the $get_children_array is an empty array, resulting in no value for $TheImageID…
So, sometimes it works, and sometimes it doesn’t (NOTE: All the posts I’ve tried have an attached image in the post content area, which was uploaded through MEDIA).
Does anyone know how to fix this?
I’ve tried this solution, but it doesn’t give any results at all (for any of my posts)
https://www.ads-software.com/support/topic/31-get_children-attachment-problem
On a particular post, I want to list all the children of that post..
I tried many things but cant get it to work.
Please help
]]>Regards
Marcus
https://www.ads-software.com/plugins/video-embed-thumbnail-generator/
]]>