Category Archives: Wordpress Tips And Tricks

Where does WordPress store image resolution in the MySQL database?

TL;DR: WordPress does not store image resolution in the database.  Nor does it store any information on the difference sizes of the image that it automatically creates.  Looks like the only interaction WP has with images and their resized versions is on initial load, after that it has no record of what’s available for use in posts.

Spent about an hour this morning searching for an answer for this, but there’s no indication that the image size is stored anywhere in the database.  Any time the image is referenced in full from WP, getimagesize is used to get the resolution. The rest of the the image attachment’s meta data is stored haphazardly in either wp_postmeta or wp_posts.  Oddly enough when using getimagesize outside of wp_get_attachment_image_src I seem to get different results (0x0 vs 9393×12500), which may have something to do with image size limits or memory limits in WP.

Here’s where you can find the data that’s stored for each image attachment:

wp_posts:
post_content = description
post_title = image title
post_excerpt = image caption

wp_postmeta:
_wp_attachment_image_alt

If you’ve created a custom taxonomy for your attachments, they’ll be found in the expected taxonomy tables (wp_termmeta, wp_terms, wp_term_relationships, wp_term_taxonomy)

Ref:

php.net/manual/en/function.getimagesize.php

developer.wordpress.org/reference/functions/wp_get_attachment_image_src/

How to remove Emoji support from WordPress

The latest version of WordPress has some pretty stupid additions to it, namely the mandatory support of “emoji”, which are one of the greatest diseases on the internet. Why they thought adding more overhead to every WordPress installation just to add this little wanted feature was a good idea is beyond me, but if you’d like to remove it from your sites, add this bit of code either to your theme’s function.php file or your own custom fuction plugin that you’ve previously created:

remove_action( ‘wp_head’, ‘print_emoji_detection_script’, 7 );
remove_action( ‘wp_print_styles’, ‘print_emoji_styles’ );

thanks to antsanchez.com for the heads up.

how to show all untagged posts in wordpress

over on www.myconfinedspace.com I was having trouble keeping track of which posts had been properly tagged or not. using this code, you’ll be able to display the untagged posts. And edit button will appear when appropriate.

Please note this is a custom page template, so just create a blank text file, rename it “untagged.php” and upload it to your theme directory.  then just create a new page through wordpress and tell it to use the “untagged” template!

<?php
/*
Template Name: untagged
*/
?>

<br />
<hr />
<?php
$temp = $wp_query;
$wp_query= null;
$wp_query = new WP_Query();
$wp_query->query(‘showposts=500′.’&paged=’.$paged);
?>
<br />
<div style=”text-align:center;font-size:31px;”>
<?php posts_nav_link(‘ · ‘, ‘previous page’, ‘next page’); ?>
</div>
<br />
<center><?php if(function_exists(‘wp_pagenavi’)) { wp_pagenavi(); } ?></center>
<br />
<?php if (have_posts()) : ?>
<?php while (have_posts()) : the_post(); ?>

<?php
$tag = get_the_tags();
if (!$tag) { ?>

<a href=”<?php the_permalink() ?>”><?php the_title(); ?>
</a> – – <?php edit_post_link(‘[Edit]’); ?><br />
<?php
}
endwhile;
endif; ?>

create

please note the large number of posts that will be shown. Since it’s only the post titles that are loading there shouldn’t be a problem with 500 of them at once, but your server may not be the uber powerhouse that mine is 😉 Another quirk of this bit of code is that each page is 500 posts of your material, and it only shows the ones that are untagged. so if you have untagged posts that are 4,000 posts back, you’ll need to click over to page 8 or 9 to see those posts pop up on this.

how to list your future posts in wordpress

Want to show what posts are coming up? add this bit of code in: