I set up a custom post type & taxonomy and registered it as a plugin.
Then i'm referencing it from an archive template like this:
<?php
/*
This loop is used in the Archive [.php] template.
*/
$post_id = get_the_ID();
$artwork_id = get_post_thumbnail_id($post_id);
$metadata = wp_get_attachment_metadata($artwork_id);
$height = $metadata['sizes']['medium']['height'];
$width = $metadata['sizes']['medium']['width'];
$src = get_the_post_thumbnail_url($post_id,'medium_large');
$class = 'attachment-'.$artwork_id;
$alt = get_the_title();
?>
<?php echo '<div class="artwork infinite-scroll-item" style="width:calc('.$width.'px * 250 / '.$height.'); flex-grow:calc('.$width.'*250/'.$height.')">'; ?>
<?php echo '<a href="'.get_the_permalink().'" style="padding-bottom:calc('.$height.' / '.$width.' * 100%);">'; ?>
<?php echo '<img src="'.$src.'" alt="'.$alt.'" class="'.$class.'" />'; ?>
<strong><?php the_title(); ?></strong> <?php echo get_the_date( 'Y' );?>, <?php the_field('materials'); ?>, <?php the_field('height'); ?>x<?php the_field('height'); ?>cm, <?php the_field('availability'); ?>
</a>
</div>
I get this error on the site: Warning: Error while sending QUERY packet. [...] /wp-includes/wp-db.php on line 2056 followed by a 503 Service Unavailable error.
Does that code look horribly inefficient? The query returns 20 posts per page and I use an infinite scroll plug-in to get further posts, approximately 50 - 80 in total.
Is there anything I could do to improve it?