Title: zonirc's Replies | WordPress.org

---

# zonirc

  [  ](https://wordpress.org/support/users/zonirc/)

 *   [Profile](https://wordpress.org/support/users/zonirc/)
 *   [Topics Started](https://wordpress.org/support/users/zonirc/topics/)
 *   [Replies Created](https://wordpress.org/support/users/zonirc/replies/)
 *   [Reviews Written](https://wordpress.org/support/users/zonirc/reviews/)
 *   [Topics Replied To](https://wordpress.org/support/users/zonirc/replied-to/)
 *   [Engagements](https://wordpress.org/support/users/zonirc/engagements/)
 *   [Favorites](https://wordpress.org/support/users/zonirc/favorites/)

 Search replies:

## Forum Replies Created

Viewing 5 replies - 1 through 5 (of 5 total)

 *   Forum: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
   
   In reply to: [automatically set the featured image](https://wordpress.org/support/topic/automatically-set-the-featured-image/)
 *  [zonirc](https://wordpress.org/support/users/zonirc/)
 * (@zonirc)
 * [15 years, 2 months ago](https://wordpress.org/support/topic/automatically-set-the-featured-image/#post-1796281)
 * [@doctorcilantro](https://wordpress.org/support/users/doctorcilantro/)
 * Sorry for a late reply, yes it should be ok in functions.php of the theme.
 * Another thing, the theme should be enable/support the featured image/post_thumbnail.
   To do this, you can use something like this: `add_theme_support('post-thumbnails');`
 * To automatically add the 1st image in the post as a featured images, you need
   to customised it a little bit. Since the code just for assign an image as a featured
   image/post thumbnail for the post. Probably by hook into post save.
 *   Forum: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
   
   In reply to: [automatically set the featured image](https://wordpress.org/support/topic/automatically-set-the-featured-image/)
 *  [zonirc](https://wordpress.org/support/users/zonirc/)
 * (@zonirc)
 * [15 years, 3 months ago](https://wordpress.org/support/topic/automatically-set-the-featured-image/#post-1796274)
 * [@doctorcilantro](https://wordpress.org/support/users/doctorcilantro/)
 * You can put it into your theme functions.php.
 *   Forum: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
   
   In reply to: [automatically set the featured image](https://wordpress.org/support/topic/automatically-set-the-featured-image/)
 *  [zonirc](https://wordpress.org/support/users/zonirc/)
 * (@zonirc)
 * [15 years, 4 months ago](https://wordpress.org/support/topic/automatically-set-the-featured-image/#post-1796263)
 * Hi jojimori,
 * This really a late reply but since I’m also had encountered such problem(automatically
   add images as featured images of the post). For a several days I try to get the
   solution and do some research in internet. Lastly I found the below solution(
   where the code is from this [codex documentation page](http://codex.wordpress.org/Function_Reference/wp_insert_attachment).
   I just make it as a function and added the last line for making it as a featured
   images.
 * Hopefully this will help other, remember the $post_id is the parent post ID(where
   the image been attach) and the $filename is the absolute path of the image files
 *     ```
       function set_featured_image($post_id,$filename) {
       	$wp_filetype = wp_check_filetype(basename($filename), null );
       	$attachment = array(
       		'post_mime_type' => $wp_filetype['type'],
       		'post_title' => preg_replace('/\.[^.]+$/', '', basename($filename)),
       		'post_content' => '',
       		'post_status' => 'inherit'
       	);
       	$attach_id = wp_insert_attachment( $attachment, $filename, $post_id );
       	// you must first include the image.php file
       	// for the function wp_generate_attachment_metadata() to work
       	require_once(ABSPATH . "wp-admin" . '/includes/image.php');
       	$attach_data = wp_generate_attachment_metadata( $attach_id, $filename );
       	if (wp_update_attachment_metadata( $attach_id,  $attach_data )) {
       		// set as featured image
       		return update_post_meta($post_id, '_thumbnail_id', $attach_id);
       	}
       }
       ```
   
 *   Forum: [Themes and Templates](https://wordpress.org/support/forum/themes-and-templates/)
   
   In reply to: [Determine if the sidebar is activate](https://wordpress.org/support/topic/determine-if-the-sidebar-is-activate/)
 *  Thread Starter [zonirc](https://wordpress.org/support/users/zonirc/)
 * (@zonirc)
 * [16 years, 4 months ago](https://wordpress.org/support/topic/determine-if-the-sidebar-is-activate/#post-1337767)
 * thanks alchymyth, actually the problem already solved where I checked the sidebar
   in sidebar.php like you said the logic in header the sidebar are not activated
   yet 🙂 so I believe it was my fault…
    Anyay thank for correcting me and point
   the problem 🙂
 * cheers
 *   Forum: [Themes and Templates](https://wordpress.org/support/forum/themes-and-templates/)
   
   In reply to: [CSS for social icon placement](https://wordpress.org/support/topic/css-for-social-icon-placement/)
 *  [zonirc](https://wordpress.org/support/users/zonirc/)
 * (@zonirc)
 * [16 years, 4 months ago](https://wordpress.org/support/topic/css-for-social-icon-placement/#post-1337573)
 * If you want to replace the icon then simply replace the **images/link-rss.gif**
   to your own image. However, if you want to make a series of different icons, 
   then you can copy the .rss a { … } and give it a different name such as **.rss2,.
   rss-socialicon** etc. Then copy/change the **background:url(images/link-rss.gif)
   no-repeat 0 0;** to other icon image such as **background:url(images/link-socialicon.
   gif) no-repeat 0 0;**
    After that find below line(not sure where the author place
   it-might be in your header.php or other pages) <span class=”rss”>….</span> and
   add a new one based on thats. For example: <span class=”socialicon”>….</span>

Viewing 5 replies - 1 through 5 (of 5 total)