Category: Documentation

Child Skin Customization

This site uses a custom child skin of the Rocked theme with the following modifications.

functions.php

The code below sorts all the archive pages for categories and tags by title (from A->Z) instead of the default reverse chronological order. The Blog and News archive pages are sorted as normal. If you want any other categories or tags to be sorted in the default order, add them to the array $leavealone on the third line below (it’s line 47 of the actual file).

add_action( 'pre_get_posts', 'my_change_sort_order'); 
    function my_change_sort_order($query){
		$leave_alone = array("Blog", "News");
		$category = single_term_title("", false);
        if(is_archive() & $query->is_main_query() & !in_array($category, $leave_alone)):
           $query->set( 'order', 'ASC' );
           $query->set( 'orderby', 'title' );
        endif;    
    };

The two functions below add the ability to display both categories (which Rocked already does) and tags (which Rocked did not) below each item’s title on an archive page. On post archives you will get the standard Rocked category listing with the author and post date. On page archives you get a list of categories and tags but not the author or post date.

function rocked_child_cat_list() {
	$categories_list = get_the_category_list( __( ', ', 'rocked' ) );
	if ( $categories_list && rocked_categorized_blog() ) {
		printf( '<span class="cat-links"><i class="fa fa-folder"></i>' . __( '%1$s', 'rocked' ) . '</span>', $categories_list );
	}
}

function rocked_child_tag_list() {
	$tags_list = get_the_tag_list( 'Related to: ', __( ', ', 'rocked' ) );
	if ( $tags_list ) {
		printf( '<span class="cat-links"><i class="fa fa-folder"></i>' . __( '%1$s', 'rocked' ) . '</span>', $tags_list );
	}
}

template parts > content.php

The content.php file has been modified from the original to show tags on each item on the blog and news post archives as well as show category and tag information on archives for pages. The specific modifications from the original are below.

<?php if ( 'post' == get_post_type() && get_theme_mod('hide_meta_index') != 1 ) : ?>
<div class="post-meta">
	<?php rocked_posted_on(); ?>
	<?php rocked_child_tag_list(); ?>
</div><!-- .entry-meta -->
<?php endif; ?>

<?php if ( 'page' == get_post_type() && get_theme_mod('hide_meta_index') != 1 ) : ?>
<div class="post-meta">
	<?php rocked_child_cat_list(); ?>
	<?php rocked_child_tag_list(); ?>
</div><!-- .entry-meta -->
<?php endif; ?>

footer.php

The footer.php file has been modified to show the Cal State copyright notice instead of the WordPress and Rocked theme acknowledgements. The copyright year will change automatically each year. The specific portion of the file that has been modified is below.

<footer id="colophon" class="site-footer" role="contentinfo">
	<div class="site-info container">
		©<?php echo date("Y"); ?> California State University
	</div><!-- .site-info -->
</footer><!-- #colophon -->