KranzKrone
Forum Replies Created
-
I found some Code for automatically set the first Image in a Post as the Featured Image.
/** * Auto Generate Thumbnail for a Post from an Image in it. */ if ( function_exists( 'add_theme_support' ) ) { add_theme_support( 'post-thumbnails' ); // This should be in your theme. But we add this here because this way we can have featured images before swicth to a theme that supports them. function easy_add_thumbnail($post) { $already_has_thumb = has_post_thumbnail(); $post_type = get_post_type( $post->ID ); $exclude_types = array(''); $exclude_types = apply_filters( 'eat_exclude_types', $exclude_types ); // do nothing if the post has already a featured image set if ( $already_has_thumb ) { return; } // do the job if the post is not from an excluded type if ( ! in_array( $post_type, $exclude_types ) ) { // get first attached image $attached_image = get_children( "order=ASC&post_parent=$post->ID&post_type=attachment&post_mime_type=image&numberposts=1" ); if ( $attached_image ) { $attachment_values = array_values( $attached_image ); // add attachment ID add_post_meta( $post->ID, '_thumbnail_id', $attachment_values[0]->ID, true ); } } } // set featured image before post is displayed (for old posts) add_action('the_post', 'easy_add_thumbnail'); // hooks added to set the thumbnail when publishing too add_action('new_to_publish', 'easy_add_thumbnail'); add_action('draft_to_publish', 'easy_add_thumbnail'); add_action('pending_to_publish', 'easy_add_thumbnail'); add_action('future_to_publish', 'easy_add_thumbnail'); }
THANK you a lot @anlino for solving this Problem of mine. ??
IT works just fine.
I like, that you Answered after all. There are lots of Developers out there, that don’t even answer once but you Mr. are great!
Hey @anlino,
at first Glance your Code-Snippet works just fine but within the ?Single-View“ of an Article in the Post it doesn’t work within/for the ?Related Posts“ at the Bottom.
There at the Bottom for the ?Related Posts“, it still shows this BLANK-IMAGE kinda Placeholder. How can i fix this or can i even fix it?
Thank you for the Help so far. ??
Forum: Themes and Templates
In reply to: [Koji] Script in Sidebar/Menu ?Oh, my bad. Seems to be that i didn’t got the latest Version.
Thank you for the quick Answer. Can be closed!
Forum: Themes and Templates
In reply to: [Hueman] Exclude a Category from Hueman Index-PageIt’s still working with the new Hueman v2.1.5 !
Forum: Themes and Templates
In reply to: [Hueman] Exclude a Category from Hueman Index-Page@can Atasever: It WORKED very well! Thank you so much. ??