bluder
Forum Replies Created
Viewing 2 replies - 1 through 2 (of 2 total)
-
Forum: Fixing WordPress
In reply to: Help me out in This WordPress Loop DesignTry this.
<?php query_posts(array( 'post_type' => 'post', 'showposts' => 5 )); $i = 0; while ( have_posts() ) : the_post(); $i++; ?> <a class="card" href="<?= get_permalink() ?>"> <?php if ($i === 1) : ?> <div class="card__meta"><?= get_the_category()[0]->cat_name ?></div> <div class="card__media"> <img src="<?php the_post_thumbnail_url('medium'); ?>"> </div> <div class="card__title"><?php the_title(); ?></div> <?php else : ?> <div class="card__title"><?php the_title(); ?></div> <?php endif; ?> </a> <?php endwhile; ?>Forum: Developing with WordPress
In reply to: WP filter for thumbnails suffixI solved this using the
wp_get_attachment_metadatafilter. Removed the suffixes-{$width}x{$height}for all sizes, and put the prefix at the beginning of the file name, instead in the beginning URL.function attachment_metadata_filter($data) { foreach ($data['sizes'] as $key => $size) { $width = $size['width']; $height = $size['height']; $fileNoSuffix = str_replace("-{$width}x{$height}", '', $data['sizes'][$key]['file']); // remove suffix $data['sizes'][$key]['file'] = "{$width}x{$height}/" . $fileNoSuffix; // add prefix } return $data; } add_filter('wp_get_attachment_metadata', 'attachment_metadata_filter');
Viewing 2 replies - 1 through 2 (of 2 total)