WordPress shortcode – snapshot of website

Display a snapshot of any website, and place it on your blog?
Use a shortcode.
Paste the following code into your functions.php file:


function wpr_snap($atts, $content = null) {
			"snap" => 'http://s.wordpress.com/mshots/v1/',
			"url" => 'http://www.ontwerps.nl',
			"alt" => 'My image',
			"w" => '400', // width
			"h" => '300' // height
        ), $atts));

	$img = '<img src="' . $snap . '' . urlencode($url) . '?w=' . $w . '&h=' . $h . '" alt="' . $alt . '"/>';
        return $img;

add_shortcode("snap", "wpr_snap");

Usage shortcode without thw first “:

["snap url="http://test.ontwerps.nl" alt="Description" w="400" h="300"]

[snap url=”http://www.google.nl” alt=”google” w=”400″ h=”300″]

Change WordPress login url

Edit .htaccess file and add the following code.
Before editing backup your .htaccess file

RewriteRule ^login$ http://website.com/wp-login.php [NC,L]

Customizing WordPress Admin

Remove the Admin Bar

putting the following in functions.php:

add_filter( 'show_admin_bar', '__return_false' );

<p>Specify the interval that WordPress should auto-save, you just have to put a single line of code in wp-config.php:</p>

define('AUTOSAVE_INTERVAL', 300); // 60 * 5, auto-saves every 5 minutes

<p>Disable autosave:</p>

function no_autosave() {

add_action( 'wp_print_scripts', 'no_autosave' );

<p>Add the following to your wp-config.php file:</p>

define('WP_POST_REVISIONS', 3); // Maximum 3 revisions per post
define('WP_POST_REVISIONS', false); // Disable revisions

<p>Empty Trash Automatically,add this line to wp-config.php </p>

define('EMPTY_TRASH_DAYS', 7 ); // Empty trash every 7 days 

Custom wordpress login

Make a custom login

copy the following piece of code, and paste it on your functions.php file

Of course your image will replace the original one so there is a size to respect. Your picture must have the following size: 333×85

//custom login

function my_custom_login_logo() {
    echo '<style type="text/css">
        h1 a { background-image:url('.get_bloginfo('template_directory').'/images/custom-login-logo.gif) !important; }

add_action('login_head', 'my_custom_login_logo');

//Custom Login Screen
function change_wp_login_url() {
echo bloginfo(‘url’);

function change_wp_login_title() {
echo get_option(‘blogname’);

add_filter(‘login_headerurl’, ‘change_wp_login_url’);
add_filter(‘login_headertitle’, ‘change_wp_login_title’);

//Change link from new WP login logo (default is wordpress.org)
function put_my_url(){
return "http://test.ontwerps.nl/"; // your URL here
add_filter(‘login_headerurl’, ‘put_my_url’);

Extend or remove some fields in User Profiles

WordPress user profiles include several contact fields (e-mail address, a URL, AIM, Yahoo, and Google Talk) and these built-in contact fields are not always useful. It is possible to extend or remove some fields with just a few lines of code in functions file. In the following code we will add a Twitter field and remove AIM, Yahoo IM, Google Talk/Jabber.

// Change user contact fields profile
function change_user_profile( $contactmethods ) {
// Add Twitter field
$contactmethods['twitter'] = 'Twitter Name (no @)';
// Remove AIM, Yahoo IM, Google Talk/Jabber

return $contactmethods;
add filter('user contactmethods','change_user_profile',10,1);

Changing excerpt

Changing excerpt lenght

In WordPress it is possible to change the excerpt length by simply returning the desired number of words as an integer. In this example we will output the first 75 words. Create a variable an put it on top of your functions.php so you can quickly change it.

// Changing excerpt length to 75 Words
$wp_excerpt_words_length = 75;
function change_excerpt_length($length) {
   return $wp_excerpt_words_length;
add_filter('excerpt_length', 'change_excerpt_length');

Changing excerpt more

The default text appended to auto-generated excerpts is (‘[…]’). Sometimes it is more suitable to change it with something else for example a link. Here below is the code to change the excerpt more with a link.

// Changing excerpt more
function change_excerpt_more($more) {
   return '<a title="Continue reading" href="%27.%20get%20permalink%28%29%20.%20%27" rel="nofollow">' . 'Continue reading' . '</a>';
add_filter('excerpt_more', 'change_excerpt_more');

Insert shortcodes in widgets

Just add a filter in functions.php, as shown below.

add_filter('widget_text', 'do_shortcode')

Now you can add shortcodes in Widgets just as you do in a normal post or page.

Allow more file types for upload

If you ever tried to upload some not so common filetypes, such as .ai to your WordPress blog, you may have experienced an error, because WordPress simply doesn’t want you to upload some other file type.
Fortunately, you can add new file types to WordPress whitelist. Paste the followingcode in your functions.php, and you’re done.

function addUploadMimes($mimes) {
    $mimes = array_merge($mimes, array(
        'ai|eps|psd|tmbundle|tmCommand|tmDragCommand|tmSnippet|tmLanguage|tmPreferences' => 'application/octet-stream'

    return $mimes;

add_filter('upload_mimes', 'addUploadMimes');

Note that file types have to be separated by a pipe.

Removing autolinks in comments

Paste the following into your functions.php file. Once you saved the file, you’ll notice that autolinks have disappeared.

remove_filter('comment_text', 'make_clickable', 9);

Post thumbnail in your RSS feed

The the_post_thumbnail() function is very useful to easily add and display a thumbnail attached to a post. Unfortunately, there’s no built-in way to display this thumbnail on your RSS feed.

Simply paste it in your functions.php, save it, and the post thumbnail will be automatically displayed on your RSS feed.

function diw_post_thumbnail_feeds($content) {
	global $post;
	if(has_post_thumbnail($post->ID)) {
		$content = '<div>' . get_the_post_thumbnail($post->ID) . '</div>' . $content;
	return $content;
add_filter('the_excerpt_rss', 'diw_post_thumbnail_feeds');
add_filter('the_content_feed', 'diw_post_thumbnail_feeds');