Skip to content

Instantly share code, notes, and snippets.

<?php
function topratings_function() {
/**
* Adds the Tasty Recipes ratings to the top of the post.
*
* @param string $content Existing post content.
* @return string
*/
add_filter( 'the_content', function( $content ) {
@aosipov
aosipov / related_posts_category.php
Created May 30, 2019 18:04
Related posts from primary category
@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 / 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 / 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 / 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 / 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 / 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 / category.php
Created November 15, 2017 19:14
add pagination to the category
<?php numeric_posts_nav(); ?>