The Definitive Guide to Setting Up WordPress in 2024: A Bristol Freelance Web Developer’s Essential Setup
In the ever-evolving landscape of website development, staying ahead of the curve...
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 the ever-evolving landscape of website development, staying ahead of the curve...
In the digital realm, your website serves as the cornerstone of your...
In the ever-evolving world of e-commerce, having a robust and flexible platform...
Being a freelance web developer, I often work on websites for start up and small businesses. The topic of social...
A nice solution for a custom WordPress Ajax login form without using a plugin. Place this anywhere you would like...
Commonly asked eCommerce questions: A nice little bit of information about #PCIDSS for @WooCommerce - http://goo.gl/BSK6Ba Lee Harris - Twitter...