Showing the Content of the ‘Posts Page’ before all Posts

If you have set a static front page, and defined a ‘posts page’, WordPress will use the index template to show the list of posts.
This also means that any content you might have entereed into the ‘posts page’ will not get shown.

Make sure to add any content before you set the page as the ‘posts page’; otherwise the editor will not be shown, and a warning message will be displayed instead.

To show this content of the ‘posts page’ before the list of posts, you can use following code (to be inserted into functions.php of a child theme, the html structure of the example below is based on Twenty Fourteen):

function page_content_on_posts_page() {
if( get_option( 'page_for_posts' ) && is_home() ) {
global $wp_query;
if( !is_paged() && $wp_query->current_post == 0 ) { ?>
<article id="post-<?php echo get_option( 'page_for_posts' ); ?>" class="<?php echo implode(  ', ', get_post_class( 'posts-page-content', get_option( 'page_for_posts' ) ) ); ?>">

<div class="entry-content">
<?php
echo apply_filters( 'the_content', get_post( get_option( 'page_for_posts' ) )->post_content );
?>
</div><!-- .entry-content -->
</article><!-- #post-## -->
<?php }
}
}

add_action( 'the_post', 'page_content_on_posts_page' );

 

 

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