emrahgunduz
always eats his vegetables
Blog RSS Feed
  • twitter
  • friendfeed
  • linkedin
  • facebook
  • vimeo
  • flickr
  • lastfm

WordPress: Include your featured post image in RSS feeds

If you want to see your featured post image in your feeds, and want them to appear when your share it in social sites, all you need is to include this code in your theme’s functions.php file:

// Featured image in RSS feeds add_filter('the_excerpt_rss', 'eg_insertthumbnailrss'); add_filter('the_content_feed', 'eg_insertthumbnailrss'); function eg_insertthumbnailrss($content) {    global $post;    if ( has_post_thumbnail( $post->ID )) {     $content = "<p>" . get_the_post_thumbnail ( $post->ID, 'thumbnail' ) . "</p><br />" . $content;   }   return $content; }

If your post has thumbnail pictures, they will appear on the top in paragraph tags. You can change how you want to see it, by manipulation the $content part in the if ( has_post_thumbnail( $post->ID )) statement.

You can also change which post image size you’d like to see. WordPress comes with three sizes by default, and one selection for the full image (thumbnail, medium, large or full). Your theme can also assign its own post thumbnail image sizes. Look for add_image_size('post-image-name'); line in your functions.php, and check the name, if you want to use your theme’s thumbnails.

This post's short url is: http://emrg.me/6h

Create sitemap.xml In WordPress Without Using Any Plugins

Everybody likes plugins, and most of them are really great (in case of WordPress). But some people like me, tend to do the work by themselves.

So, here is a simple code that will re-create a sitemap.xml file, everytime you publish a post or page. Copy the code and paste it to your theme’s functions.php file (wp-content/themes/your_theme_folder/functions.php).

PS. I added <?php … ?> for clean code coloring, you will not need those lines.

<?php add_action("publish_post", "eg_create_sitemap"); add_action("publish_page", "eg_create_sitemap"); function eg_create_sitemap() {   $postsForSitemap = get_posts(array(     'numberposts' => -1,     'orderby' => 'modified',     'post_type'  => array('post','page'),     'order'    => 'DESC'   ));     $sitemap = '<?xml version="1.0" encoding="UTF-8"?>';   $sitemap .= '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">';     foreach($postsForSitemap as $post) {     setup_postdata($post);         $postdate = explode(" ", $post->post_modified);         $sitemap .= '<url>'.       '<loc>'. get_permalink($post->ID) .'</loc>'.       '<lastmod>'. $postdate[0] .'</lastmod>'.       '<changefreq>monthly</changefreq>'.     '</url>';   }     $sitemap .= '</urlset>';     $fp = fopen(ABSPATH . "sitemap.xml", 'w');   fwrite($fp, $sitemap);   fclose($fp); } ?>

If you’ve got custom post types, you’ll need to add the registered taxonomy to ‘post_type’ array part of the code.

For a big blog with thousands of posts, creating a sitemap.xml file with every post publish action might not be a good solution, so keep that in mind.

This post's short url is: http://emrg.me/5v

Random Rotate Maxscript Version 1.1

Random Rotate Maxscript Version 1.1

I’ve changed how random rotate works, and added a few new features. First of all, rotation now uses quaternion, which is better than euler rotation. I was converting euler angles to quats, this was getting rid of the gimbal lock, but it was not enough for adding new ways of rotation to the script.

Download Random Rotate 1.1

So, with new version, you are now able to rotate an object randomly bu using objects’ local or world coordinates, or the screen coordinate itself. Also, it is now possible to use the selection center, or another object’s pivot.

I don’t know where you can use these new features, but it was fun building them in. Have fun :)

Here are some screenshots:

  • Drag drop to start the script
  • Script popup appears
  • World Z only random rotation
  • Screen Z only random rotation
  • Selection center Z only random rotation
  • Selected object Z only random rotation

This post's short url is: http://emrg.me/8h

Random Material Assigner for Objects with Multiple MaterialIDs

Random Material Assigner for Objects with Multiple MaterialIDs

Works on one or multiple object selections. Script detects the materialID count and creates a multi-sub material(s) for the selected object(s), and changes the diffuse channel with a random color. If there is only one materialID on the object, script simply creates a standart material.

Download Random Material Assigner for Objects with MaterialID

As this is a macroscript, after running it, you need to add it to a quad menu, or an icon on a toolbar, or to a menu. Script’s category is “emrahgunduz.com”.

Keep these in mind

  • Created materials are named after the object’ own name.
  • Materials in the multi-sub object will be “Standard”.
  • Changes diffuse channel color with a random one.
  • Works only with poly, mesh or patch object. There is no nurbs or basic object support.

Here are some screenshots

  • Drag drop script for installation
  • Add script to your quad menu or to a toolbar
  • Select your object and run the script
  • Your object is randomly materialized

This post's short url is: http://emrg.me/8i


Fatal error: Cannot use string offset as an array in /home/emrahgun/public_html/wp-content/themes/emrahgunduz/footer.php on line 10