Archives

Append to Content

If you need to auto-append information to the end of your page/post content, there’s an easier way to do it than editing your theme.

add_filter( 'the_content', 'append_to_content' );
function append_to_content($content) {
	global $post;
	//if you want to restrict this to a specific post type
	if (get_post_type($post) == 'post') {
		$content .= '<p style="text-align:center;">***</p>';
	}
	return $content;
}

Can be especially useful for auto-appending custom field information

Add Featured Image Thumbnail to Posts Page

Customize the information that is displayed on the ‘posts’ page

Adding a column labeled “Thumbnail” (and delete the “Comments” column).

add_filter( 'manage_edit-post_columns', 'set_columns' );
function set_columns($columns) {
	$columns['thumbnail'] = 'Thumbnail';
	unset( $columns['comments'] );
	return $columns;
}

Now we need to tell WordPress what to do with this new “Thumbnail” space. Here, we’re checking for the existence of a featured image and displaying it, or noting that there is no thumbnail.

add_action( 'manage_posts_custom_column', 'fill_columns' );
function fill_columns($column) {
	global $post;
	switch($column) {
		case 'thumbnail' :
			if (has_post_thumbnail($post->ID))
				echo get_the_post_thumbnail($post->ID, array(50, 50));
			else
				echo '<em>no thumbnail</em>';
		break;
	}
}