A Real ‘Full Width Page’ Template for Twenty Fourteen

To create a real full width page – with no sidebars whatsoever – in your WordPress site while using a child theme of the default theme Twenty Fourteen, program this page template file with the file name real-full-width.php (important as this is referenced in the CSS) and save it in a sub-folder /page-templates in the child theme:

<?php
/**
 * Template Name: Real Full Width Page
 *
 * @package WordPress
 * @subpackage Twenty_Fourteen
 * @since Twenty Fourteen 1.0
 */

get_header(); ?>

<div id="main-content" class="main-content">

<?php
	if ( is_front_page() && twentyfourteen_has_featured_posts() ) {
		// Include the featured content template.
		get_template_part( 'featured-content' );
	}
?>

	<div id="primary" class="content-area">
		<div id="content" class="site-content" role="main">
			<?php
				// Start the Loop.
				while ( have_posts() ) : the_post();

					// Include the page content template.
					get_template_part( 'content', 'page' );

					// If comments are open or we have at least one comment, load up the comment template.
					if ( comments_open() || get_comments_number() ) {
						comments_template();
					}
				endwhile;
			?>
		</div><!-- #content -->
	</div><!-- #primary -->
</div><!-- #main-content -->

<?php
get_footer();

Add this section to style.css of the child theme:

.page-template-page-templatesreal-full-width-php .site {
	width: 100%;
}

.page-template-page-templatesreal-full-width-php  .hentry {
	margin: 0 auto 48px;
	max-width: 90%;
}

.page-template-page-templatesreal-full-width-php .site-content .entry-header,
.page-template-page-templatesreal-full-width-php .site-content .entry-content,
.page-template-page-templatesreal-full-width-php .site-content .entry-summary,
.page-template-page-templatesreal-full-width-php .site-content .entry-meta,
.page-template-page-templatesreal-full-width-php .page-content {
	margin: 0 auto;
	max-width: 90%;
}

.page-template-page-templatesreal-full-width-php .main-content,
.page-template-page-templatesreal-full-width-php .content-area {
	float: left;
	width: 100%;
}
.page-template-page-templatesreal-full-width-php .site-content,
.page-template-page-templatesreal-full-width-php .site-main .widecolumn {
	margin-left: 0;
}

.page-template-page-templatesreal-full-width-php .site:before {
	width: 0;
}

.page-template-page-templatesreal-full-width-php .site-content {
	margin-left: 0;
	margin-right: 0;
}

(not optimized)

Activate the template in the ‘Edit Page’ dashboard page, under ‘Page Attributes’ by ticking ‘Real Full Width Page’.

Featured Image in Header of Archive Pages in Twenty Eleven

To show the ‘featured image’ of the top post as header image in an archive page in the Twenty Eleven theme, edit header.php in the child theme;

change this section:

<?php
/*
* The header image.
* Check if this is a post or page, if it has a thumbnail, and if it's a big one
*/
if ( is_singular() && has_post_thumbnail( $post->ID ) &&
( /* $src, $width, $height */ $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), array( $header_image_width, $header_image_width ) ) ) &&
$image[1] >= $header_image_width ) :
// Houston, we have a new header image!
echo get_the_post_thumbnail( $post->ID, 'post-thumbnail' );
else :
// Compatibility with versions of WordPress prior to 3.4.
if ( function_exists( 'get_custom_header' ) ) {
$header_image_width  = get_custom_header()->width;
$header_image_height = get_custom_header()->height;
} else {
$header_image_width  = HEADER_IMAGE_WIDTH;
$header_image_height = HEADER_IMAGE_HEIGHT;
}
?>
<img src="<?php header_image(); ?>" width="<?php echo $header_image_width; ?>" height="<?php echo $header_image_height; ?>" alt="" />
<?php endif; // end check for featured image or standard header ?>

to:

<?php
/*
* The header image.
* Check if this is an archive and if the latest post has a thumbnail, and if it's a big one
* or Check if this is a post or page, if it has a thumbnail, and if it's a big one
*/
if ( is_archive() ) :
the_post();
$archive_thumb = '';
if( has_post_thumbnail( $post->ID ) &&
( /* $src, $width, $height */ $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), array( $header_image_width, $header_image_width ) ) ) &&
$image[1] >= $header_image_width ) :
$archive_thumb = get_the_post_thumbnail( $post->ID, 'post-thumbnail' );
endif;
rewind_posts();
endif;
if ( is_archive() && $archive_thumb ) :
echo $archive_thumb; //the featured image of the latest post in the archive
elseif ( is_singular() && has_post_thumbnail( $post->ID ) &&
( /* $src, $width, $height */ $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), array( $header_image_width, $header_image_width ) ) ) &&
$image[1] >= $header_image_width ) :
// Houston, we have a new header image!
echo get_the_post_thumbnail( $post->ID, 'post-thumbnail' );
else :
// Compatibility with versions of WordPress prior to 3.4.
if ( function_exists( 'get_custom_header' ) ) {
$header_image_width  = get_custom_header()->width;
$header_image_height = get_custom_header()->height;
} else {
$header_image_width  = HEADER_IMAGE_WIDTH;
$header_image_height = HEADER_IMAGE_HEIGHT;
}
?>
<img src="<?php header_image(); ?>" width="<?php echo $header_image_width; ?>" height="<?php echo $header_image_height; ?>" alt="" />
<?php endif; // end check for featured image or standard header ?>

Alphabetize Category Posts Using ‘pre_get_posts’ Action

Occasionally you want to have a different sort order in some of the category archives, for example, you want to output the posts of a specific category in alphabetical order.
Instead of having to create a category template for each of those categories and to add a custom query to change the query parameters, WordPress providdes the ‘pre_get_posts’ action where you can add a corresponding function:

function category_archive_sort_alphabetical( $query ) {
    if ( is_admin() || ! $query->is_main_query() )
        return;

    if ( is_category( array( 'Category One', 'category-two', 'Another Cat' ) ) ) {
		$query->set( 'orderby', 'title' );
		$query->set( 'order', 'ASC' );
        return;
    }
}
add_action( 'pre_get_posts', 'category_archive_sort_alphabetical', 1 );

resources:
http://codex.wordpress.org/Plugin_API/Action_Reference/pre_get_posts
http://codex.wordpress.org/Function_Reference/is_category

WordPress Changing Pluggable Functions Without Child Theme

A new concept (?) – to change a pluggable function of a WordPress theme without creating a child theme.

Example – to remove the  post tags output from the posts of Twenty Twelve.

Often, these things can be done by editing the styles of the theme, however in this case, CSS would not work as the tags don’t have their own CSS class.

Creating a child theme is usually recommended as the easiest option; but this might be over the top if the only changed paremeters are from some pluggable functions.

The alternative way would be to create a plugin to alter (in this example) the post-meta-data output, which is done through the function ‘twentytwelve_entry_meta()’.

How to:
use FTP to create a file, for example with the file name twentytwelve-entry-meta-modified.php, in the /wp-content/plugins/ folder; and add this example code (http://pastebin.com/7dMVvC9E)

<?php
/*
Plugin Name: Entry Meta Twenty Twelve Modified
Plugin URI: n/a
Description: personalization of the entry meta of Twenty Twelve without child theme; in this particular example the removal of the tags.
Version: 1.0
Author: alchymyth
Author URI: http://transformationpowertools.com
License: GPL2
*/

add_action( 'setup_theme', 'modify_pluggable_theme_functions' );

function modify_pluggable_theme_functions() {

if( wp_get_theme() == 'Twenty Twelve' && get_stylesheet_directory() == get_template_directory() ) :
//check for the right theme and that no child theme is used
function twentytwelve_entry_meta() {
// Translators: used between list items, there is a space after the comma.
$categories_list = get_the_category_list( __( ', ', 'twentytwelve' ) );

$date = sprintf( '<a href="%1$s" title="%2$s" rel="bookmark"><time datetime="%3$s">%4$s</time></a>',
esc_url( get_permalink() ),
esc_attr( get_the_time() ),
esc_attr( get_the_date( 'c' ) ),
esc_html( get_the_date() )
);

$author = sprintf( '<span><a href="%1$s" title="%2$s" rel="author">%3$s</a></span>',
esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ),
esc_attr( sprintf( __( 'View all posts by %s', 'twentytwelve' ), get_the_author() ) ),
get_the_author()
);

if ( $categories_list ) {
$utility_text = 'This entry was posted in %1$s on %2$s<span> by %3$s</span>.';
} else {
$utility_text = 'This entry was posted on %2$s<span> by %3$s</span>.';
}

printf(
$utility_text,
$categories_list,
$date,
$author
);
}
endif;
}
?>

The code checks that Twenty Twelve is the active theme, and that no child theme is activated.

Activate the plugin ‘Entry Meta Twenty Twelve Modified’ as usual from within dashboard – plugins.

http://codex.wordpress.org/Pluggable_Functions
http://codex.wordpress.org/FTP_Clients
http://codex.wordpress.org/Plugins
http://codex.wordpress.org/Writing_a_Plugin
http://codex.wordpress.org/Plugin_API/Action_Reference