WordPress: Restrict direct access to files – Prevent hotlinking
A useful bit of code to prevent files from being accessed (or...
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
A useful bit of code to prevent files from being accessed (or...
In the early days (2003), WordPress was essentially a blogging tool and...
To allow the editor user role to have full access to Gravity...
So, you have just got your new website and you want to get it to the top of search engines....
Handy bit of code you can use in your custom templates that grabs the all the page or post data by ID:...
A quick snipped of code that can be used attach a function to the escape key. Great for adding or...