Make carousel slider from last 5 posts product from related category with prev and next button
Make carousel slider from last 5 posts product from related category with prev and next button
Make carousel slider from last 5 posts product from related category with prev and next button
<?php $post_id = get_queried_object_id(); $bla = “myImageURL”; // Set the image URL $image_url = $bla; // Check if the image already exists in the media library $existing_image = get_posts(array( ‘post_type’ => ‘attachment’, ‘meta_key’ => ‘_wp_attached_file’, ‘meta_value’ => sanitize_file_name(basename($image_url)) )); if (!$existing_image) { // Image does not exist in the media library, so download it $image_id … Read more
If you changed the picture and the size still the same, it’s either your code that displays it or just browser caching. If you wanted to view the image after you update the size, try using incognito. I’m being quite abstract here, give more info if this doesn’t work.
There is no need to store product setting product wise as there will be only one featured product. You can store the featured_product_id in options table. And whenever a product is featured you just override the record in the options table, that why you can avoid the deselecting hassle of previously selected featured product.
How to list blog post from subdirectory wordpress install to the main site
Remove the excerpt and “… Read More” from the featured content on the home page with child theme
If you want to show the File type of featured image. then try the below code. <?php $id1 = get_post_thumbnail_id($post->ID); $type = get_post_mime_type( $id1 ); $mime_type = explode(“https://wordpress.stackexchange.com/”, $type); $type=”.”.$mime_type[‘1’]; echo $type; ?> It will display the exact extension that you want “.jpeg” from “image/jpeg” Here “$post->ID” is current post id (or the id of … Read more
Following function calculate file size, just you need change ‘/myfile/image.jpg’ with your featured image variable. <?php function file_size($url){ $size = filesize($url); if($size >= 1073741824){ $fileSize = round($size/1024/1024/1024,1) . ‘GB’; }elseif($size >= 1048576){ $fileSize = round($size/1024/1024,1) . ‘MB’; }elseif($size >= 1024){ $fileSize = round($size/1024,1) . ‘KB’; }else{ $fileSize = $size . ‘ bytes’; } return $fileSize; … Read more
Basic check of aspect ratio. Display as landscape, square or portrait if ( !has_post_thumbnail()) { return ‘Error’; } else { $image = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), ”); $image_w = $image[1]; $image_h = $image[2]; if ($image_w > $image_h) { echo ‘landscape’; } elseif ($image_w == $image_h) { echo ‘square’; } else { echo ‘portrait’; } }
From this answer: Let’s say you want to fetch the ID of the immediately previous post based on the current post’s ID. This is what you’d do: get_previous_post_id( $post_id ) { // Get a global post reference since get_adjacent_post() references it glob al $post; // Store the existing post object for later so we don’t … Read more