Show Page Title and Content of the ‘Posts Page’ in WordPress

When you set a static front page and at the same time set a Posts Page, WordPress will automatically use index.php (or home.php *) to display the Posts Page; as described in the Codex, you’ll lose the output of the title and content of that page.
To show this information on the Posts Page, for instance as an introduction for the posts, add some code to index.php (or home.php):

<?php //this is to output the page title and content for a 'page for posts' page as set under  'settings' - 'reading'
	if( is_home() && !is_paged() && get_option('page_for_posts') ) { 
	$posts_page_id = get_option('page_for_posts'); ?>			
	<header class="entry-header">
		<h1 class="entry-title"><?php echo get_the_title($posts_page_id); ?></h1>
	</header><!-- .entry-header -->
	<?php $posts_page = get_page( $posts_page_id ); ?>
	<div class="entry-content posts-page-entry-content">
	<?php echo apply_filters('the_content', $posts_page->post_content); ?>
	</div><!-- .posts-page-entry-content -->	
<?php } ?>

Show Description for Header Images in Twenty Eleven

This code is for a child theme of Twenty Eleven, because the direct editing of the default theme is not recommended.

Since wp3.4, the function get_custom_header() takes care of some of the information of the header images, such as width, height, and also the description or attachment id.

If added in header.php of the child theme, before:

<?php endif; // end check for removed header image ?>

the code below extracts the description information and outputs it below the header image:

<?php 
if ( function_exists( 'get_custom_header' ) && is_child_theme() ) :
if( get_custom_header()->description ) {
$header_description = get_custom_header()->description;
} elseif ( is_singular() && has_post_thumbnail( $post->ID ) && ( /* $src, $width, $height */ $header_img = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), array( $header_image_width, max($header_image_width,$header_image_height) ) ) ) && $header_img[1] >= $header_image_width ) {
$header_img_details = get_posts(array('p' => get_post_thumbnail_id( $post->ID ), 'post_type' => 'attachment'));
$header_description = $header_img_details[0]->post_content;
} elseif( $att_id = get_custom_header()->attachment_id ) { 
$header_img_details = get_posts(array('p' => $att_id, 'post_type' => 'attachment'));
$header_description = $header_img_details[0]->post_content;
} 
if( $header_description ) echo '<span class="header-description">' . $header_description . '</span>'; 
endif; 
?>

A commented version of the code is in pastebin http://pastebin.com/VbjxyMRF .

Advanced Filter for Tag Cloud Widget Css Classes

tag cloud widget colored with css
tag cloud widget advanced color styling

The default tag cloud widget does not offer a lot of formatting possibilities, partly because it only outputs one css class with a reference to the tag ID.
It uses an inline style, which outputs the font-size, to distinguish the tags according the number of post they belong to.

This filter function is coded to add a css class with the tag slug .tag-slug-{slug} and with a rounded tag size .tag-size-{number}, and to remove the inline style.

add_filter ( 'wp_tag_cloud', 'tag_cloud_widget_advanced_classes' );  

function tag_cloud_widget_advanced_classes( $taglinks ) { 
	$tags = explode('</a>', $taglinks);
	$regex1 = "#(.*tag-link[-])(.*)(' title.*)#e";         
	$regex2 = "#(.*style='font-size:)(.*)((pt|px|em|pc|%);'.*)#e"; 
	$regex3 = "#(style='font-size:)(.*)((pt|px|em|pc|%);')#e";         
	$regex4 = "#(.*class=')(.*)(' title.*)#e";         
	foreach( $tags as $tag ) {         
		$tag = preg_replace($regex1, "('$1$2 tag-slug-'.get_tag($2)->slug.'$3')", $tag ); //add .tag-slug-{slug} class   
		$size = preg_replace($regex2, "(''.round($2).'')", $tag ); //get the rounded font size       
		$tag = preg_replace($regex3, "('')", $tag ); //remove the inline font-size style
		$tag = preg_replace($regex4, "('$1tag-size-'.($size).' $2$3')", $tag ); //add .tag-size-{nr} class
		$tagn[] = $tag;
	}     
	$taglinks = implode('</a>', $tagn);     
return $taglinks; 
}

For the code, also see the pastebin.

The added css classes can for instance be used to color the tags according to the number of appearance; as you can see here in the tag cloud when you scroll down on the left.

Editing Widget Parameters per Filter Function WordPress

If you want to change the parameters of the default widgets, for instance the font sizes of the tag cloud widget, you will notice that you can’t access the codes directly.

Editing the core files in the /wp-includes folder is obviously not an option.

Luckily, most of the default widgets are now applying filters to the parameters;
for example, in this the line the filter gets applied for the  tag cloud widget – in /wp-includes/default-widgets.php:

wp_tag_cloud( apply_filters('widget_tag_cloud_args', array('taxonomy' => $current_taxonomy) ) );

Add a filter function to functions.php of your theme;
for example changing the font size range for the tags:

(corrected 05 Feb 2013)

add_filter('widget_tag_cloud_args','set_tag_cloud_sizes');
function set_tag_cloud_sizes($args) {
$args = array_merge( $args, array('smallest' => 12, 'largest' => 19) );
return $args; }

Alternative code:

add_filter('widget_tag_cloud_args','set_tag_cloud_sizes');
function set_tag_cloud_sizes($args) {
$args['smallest'] = 12;
$args['largest'] = 19;
return $args; }

Another example – to show only tags from the current single post:

add_filter('widget_tag_cloud_args','single_post_tag_cloud_tags');
function single_post_tag_cloud_tags($args) {
if( is_single() && $args['taxonomy'] == 'post_tag' ) {
global $post;
$post_tag_ids = wp_get_post_tags( $post->ID, array( 'fields' => 'ids' ) );
$args = array_merge( $args, array('include' => implode(',',$post_tag_ids)) );
}
return $args;
}

See the codex chapter of wp_tag_cloud()   for all possible parameters.

Another similar example – excluding the default category ‘uncategorized’ from the category widget:

add_filter('widget_categories_args','exclude_default_cat');
function exclude_default_cat($args) {
$args['exclude'] = '1';
return $args;
}

A further example – removing the output of the category description as title attributes in the category widget:

add_filter('widget_categories_args','remove_cat_description_widget');
function remove_cat_description_widget($args) {
$args['use_desc_for_title'] = 0;
return $args;
}

Here is the list of all filters for the default widgets:

'widget_pages_args'
'widget_links_args'
'widget_archives_dropdown_args'
'widget_archives_args'
'widget_text'
'widget_categories_dropdown_args'
'widget_categories_args'
'widget_tag_cloud_args'