Skip to content

u/Trevsweb

In this archive from Nov 2011 to Jun 2025

8
posts
71
comments
4
media
629
score

I found a theme functions.php script that will look through your posts/custom posts and add missing thumbnails. the original code was just looking for image mimetypes which I removed so it looks for the first attachment as highlighted below. hope that helps anyone looking all night like me :P not the most elegant but it works.

//check the system for posts that dont have featured images and add them

​

function autoset_featured() {

global $post;

$already_has_thumb = has_post_thumbnail($post->ID);

if (!$already_has_thumb) {

$attached_image = get_children( "post_parent=$post->ID&post_type=attachment&numberposts=1" );

if ($attached_image) {

foreach ($attached_image as $attachment_id => $attachment) {

set_post_thumbnail($post->ID, $attachment_id);

}

}

}

}

add_action('the_post', 'autoset_featured');

add_action('save_post', 'autoset_featured');

add_action('draft_to_publish', 'autoset_featured');

add_action('new_to_publish', 'autoset_featured');

add_action('pending_to_publish', 'autoset_featured');

add_action('future_to_publish', 'autoset_featured');

​

add_shortcode('thumbnail', 'thumbnail_in_content');

1 points

Been using WordPress for years. While I think splitting paragraphs is weird adding photos and inline photos really has been improved. Love just adding a YouTube clip too without a ridiculous plugin. Hope more Devs add loads of interesting stuff to it soon. I found the switch over super simple. Didn't have to painstakingly add new CSS to my theme. It just worked.

2 points

I'm with Site5 they were great, customer service really good too. but their resource counter is just whacky. caused me so many problems... would have to chase up spikes in data for one day in the month (most likely caused by spam) but not really helpful in terms of diagnosing the issue. had to delete many of my websites just to tow the line. ran out of time to move to another provider so I'm with them for one more year

1 points

Keyboard shortcuts

Move and act

jork
Next / previous post or comment
Enteroro
Open the post
f
Open the media viewer
s
Save
h
Hide (the toast has Undo)
Tab
Right after an action: the toast's Undo
x
Collapse the comment
v
Next layout: cards, compact, grid

Go to

/
Search
gthenh
Home
gthena
All
gthens
Subreddits
gthenl
Library
?
This list
Esc
Close a menu or this list

In the viewer

←or→
Previous / next file
↑or↓
Previous / next post
korj
Previous / next post
Space
Play / pause
m
Mute
z
Zoom
s
Save
o
Open the post (on its own page: back to it)
Esc
Close

Keys do nothing while you type in a box.