Leveraging AI to Supercharge Your WordPress Business Website
In today’s competitive digital landscape, every business website needs an edge to...
24.May.2022 | Code Snippets, Wordpress
Get the featured image dimensions (width and height) in WordPress. Paste the following code in the single.php file.
<?php
$post_id = get_the_ID();
$image_data = wp_get_attachment_image_src( get_post_thumbnail_id($post_id), "thumbnail" );
$image_width = $image_data[1];
$image_height = $image_data[2];
?>
If you want to get a specific featured image and place it anywhere other than single.php, change the $post_id variable to the post ID you want to get the featured image from.
Share
In today’s competitive digital landscape, every business website needs an edge to...
WordPress has come a long way since its humble beginnings in 2003....
In the ever-evolving landscape of website development, staying ahead of the curve...
A useful bit of code to prevent files from being accessed (or hotlinked) in WordPress. Prevent files from being directly...
I came across this when looking for a purpose built, fully customisable calendar - https://fullcalendar.io/ Im just starting to work with...
To exclude draft posts from appearing in the ACF Relationship field, add this code to your functions.php file. All you...