Hello,
It looks like you’re missing some code. Try re-copying it from where you found it.
You’re looking for a line something like
add_action( <em>hook_name</em>, 'category_specific_post_thumbnails' );
or
add_filter( <em>hook_name</em>, 'category_specific_post_thumbnails' );
where hook_name could be almost anything.
Did you have any luck getting your snippet to work?
Thread Starter
sorto
(@sorto)
I did not. I added the add_action with tag of transition_post_status and now I see and error message:
Warning: Cannot modify header information – headers already sent by (output started at /wp-content/plugins/code-snippets/code-snippets.php(398) : eval()’d code:8) in /wp-includes/pluggable.php on line 881
The add_action code:
add_action( ‘transition_post_status’, ‘category_specific_post_thumbnails’ );
I received this error on all of the post modification hooks(post_publish, post_save, etc). It is probably not the correct hook for the code.
I have a series of posts that get published via RSS feeds and they come in without featured images, so no thumbnail on the main pages but they all go to the same category. I had hoped to set the featured image for all new published posts in this category to a single image for that category. I can accomplish this by changing the functions.php, but prefer your tool for theme upgrades/changes, visibility, etc.
I am very skilled with PHP, though, so this may be a bit out of reach.
Also, a feature request – is it possible to create a central repository for all code snippets? It would be pretty great to create a library of snippets that can be used on multiple sites.
Such libraries already exist:
Also see:
There are plenty more out there.
Try hooking it to these filters:
add_filter('the_excerpt_rss', 'category_specific_post_thumbnails');
add_filter('the_content_feed', 'category_specific_post_thumbnails');
Let me know if it works.