Last active
May 31, 2016 18:21
-
-
Save jeherve/c0352f554008673823677ccece7e31f1 to your computer and use it in GitHub Desktop.
Random classes for each post.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Plugin Name: Random classes for each post | |
* Plugin URI: http://jeremy.hu | |
* Description: Random classes for each post | |
* Version: 1.0 | |
* Author: Jeremy Herve | |
* Author URI: http://jeremy.hu | |
* Text Domain: jeherve | |
* Domain Path: /languages/ | |
* License: GPL2 | |
*/ | |
/** | |
* Add a random class to each post | |
* | |
* Class will use a random number between 1 and 5 | |
* We'll then use that class to use different fonts for our post titles. | |
*/ | |
function jeherve_rand_num_post_class( $classes ) { | |
$classes[] = 'rand_' . mt_rand( 1, 5 ); | |
return $classes; | |
} | |
add_filter( 'post_class', 'jeherve_rand_num_post_class' ); | |
/** | |
* You can then use those classes in your theme stylesheet, to apply different styles to each post. | |
* In the example below, I change the post title's font randomly. | |
* | |
* .home .rand_1 .entry-header h1.entry-title { | |
* font-family: Lora, Georgia, serif; | |
* font-weight: 700; | |
* } | |
* | |
* .home .rand_2 .entry-header h1.entry-title { | |
* font-family: Monoton, Georgia, serif; | |
* font-weight: 400; | |
* } | |
* | |
* .home .rand_3 .entry-header h1.entry-title { | |
* font-family: Medula One, Georgia, serif; | |
* font-weight: 400; | |
* font-size: 7rem; | |
* } | |
* | |
* .home .rand_4 .entry-header h1.entry-title { | |
* font-family: Pacifico, Georgia, serif; | |
* font-weight: 400; | |
* } | |
* | |
* .home .rand_5 .entry-header h1.entry-title { | |
* font-family: Abril Fatface, Georgia, serif; | |
* font-weight: 400; | |
* } | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment