Skip to content

Instantly share code, notes, and snippets.

@aosipov
aosipov / 2011 Updated Clearfix
Last active October 6, 2016 19:28
CSS Snippets
.clearfix:before, .container:after { content: ""; display: table; }
.clearfix:after { clear: both; }
/* IE 6/7 */
.clearfix { zoom: 1; }
@aosipov
aosipov / Autocompletion with HTML5 datalists
Created October 8, 2013 21:06
Hyper useful, ready to use HTML5 snippets
<input name="frameworks" list="frameworks" />
<datalist id="frameworks">
<option value="MooTools">
<option value="Moobile">
<option value="Dojo Toolkit">
<option value="jQuery">
<option value="YUI">
</datalist>
@aosipov
aosipov / category.php
Created November 15, 2017 19:14
add pagination to the category
<?php numeric_posts_nav(); ?>
@aosipov
aosipov / site.css
Created November 16, 2017 22:28
add icon to the post thumbnail
article{
position:relative;
&:after{
content: "\f15c";
font-family: FontAwesome;
font-style: normal;
font-weight: normal;
text-decoration: inherit;
/*--adjust as necessary--*/
color: $brand-main-color;
@aosipov
aosipov / functions.php
Created November 16, 2017 23:53
numbered pagination
// numbered pagination
function pagination($pages = '', $range = 4)
{
$showitems = ($range * 2)+1;
global $paged;
if(empty($paged)) $paged = 1;
if($pages == '')
{
@aosipov
aosipov / another_widget
Created November 17, 2017 05:18
related posts snippets
<div class="relatedposts">
<h3>Related posts</h3>
<?php
global $post;
setup_postdata( $post );
echo "Post's ID: " . get_the_ID();
?>
<?php
$orig_post = $post;
global $post;
@aosipov
aosipov / content.php
Created November 23, 2017 21:25
author avatar block
<div class="author-block">
<div class="author-avatar">
<?php echo get_avatar( get_the_author_meta( 'ID' ), 48 );?>
</div>
<div class="by">by</div>
<div class="author-name"><?php the_author(); ?></div>
<div class="timestamp"><?php the_modified_time('F j, Y'); ?></div>
</div>
@aosipov
aosipov / functions.php
Created January 17, 2018 21:01
social sharing with Pinterest first image
//Get the first image from the post
function get_first_image_url() {
global $post, $posts;
$first_img = '';
ob_start();
ob_end_clean();
$output = preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $post->post_content, $matches);
$first_img = $matches[1][0];
@aosipov
aosipov / functions.php
Created January 17, 2018 21:02
Social sharing with Pinterest thumbnail
// Social sharing
function social_sharing_buttons($content) {
global $post;
if(is_singular() || is_home()){
// Get current page URL
$crunchifyURL = urlencode(get_permalink());
// Get current page title
@aosipov
aosipov / related_posts_category.php
Created May 30, 2019 18:04
Related posts from primary category