Links Image in “Catalog” Page to Posts

In your function virtarich_katalog_function wrap the thumbnail with an <a> link tag like this: function virtarich_katalog_function() { global $post; $vtr_query = new WP_Query(‘showposts=10000’); while ($vtr_query->have_posts()) : $vtr_query->the_post(); ?> <div class=”col-md-3 ikibro”> <div class=”wpagen-produk”> <div class=”katalog-gambar-center”> <div class=”katalog-gambar”><a href=”https://wordpress.stackexchange.com/questions/260406/<?php the_permalink() ?>” title=”<?php the_title(); ?>”><?php virtarich_thumb_normal() ?></a></div> </div> <div class=”katalog-title”><?php the_title(); ?></div> <div class=”katalog-harga”>Rp <?php virtarich_harga(); ?><span … Read more

Using Switch Statement to Change Image According to Last Digit of Topic ID

I would try something like this: function bg_image_topic_titlearea() { if ( ! function_exists( ‘bbp_get_topic_id’ ) ) { return false; } if ( ! $letztezifferimgs = bbp_get_topic_id() ) { return false; } $letztezifferimgs = substr( $letztezifferimgs, – 1 ); // switch … return true; } I would recommend checking to make sure the function call (bbp_get_topic_id();) … Read more

Manipulating images inside post content

Because the old image_send_to_editor function did NOT include the wp-image-xxxxx class with the image ID, we have to make database queries to find the correct ID for a given image. Making database queries for every image does not seem like a good idea. The only real solution is to manually delete and re-add the images … Read more

Optimize and delete images in WordPress

Good question, I have a chance to write a small wrapper that basically implements such functionality… I was thinking about when I should run my optimization and what exactly I should process files. Ended up in next conclusions… The main Image will be changed somewhere later, using wp_cron schedule. Nothing particularly interesting… you taking your … Read more

Resize External Image

I wrote this function for you, which will first make a copy of the external image, crop it , and return the ID of it: function external_image_loader ($image_url, $post_id, $title) { $img_name = basename ($image_url); global $wpdb; $query = “SELECT post_id FROM {$wpdb->postmeta} WHERE meta_value=”$img_name””; $id = $wpdb->get_var($query); if (is_numeric($id)) { return $id; } else … Read more