Created
September 13, 2019 19:00
-
-
Save JudeRosario/0f64f6eb5b122a1acaab6819b9ba8819 to your computer and use it in GitHub Desktop.
Custom code for image-sizes myotspot
This file contains hidden or 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
add_image_size( 'home-thumbnail', 374, 211 ); | |
function pexeto_get_recent_posts_column_layout_html($recent_posts, $columns, $show_content = true, $thumb_height = null){ | |
$html=''; | |
$img_size = pexeto_get_image_size_options($columns, 'blog'); | |
if($thumb_height!==null){ | |
$img_size['height'] = $thumb_height; | |
} | |
foreach ($recent_posts as $i=>$p) { | |
setup_postdata( $p ); | |
$format = get_post_format( $p ); | |
$add_class = ($i%$columns==$columns-1) ? ' nomargin':''; | |
if($i%$columns==0){ | |
$html.=sprintf('<div class="cols-wrapper cols-%s">', $columns); | |
$opened = true; | |
} | |
$has_header = false; | |
$html.=sprintf('<div class="col rp%s">', $add_class); | |
if(!in_array($format, array('quote', 'aside'))){ | |
$has_header = false; | |
$html.='<div class="rp-header">'; | |
if($format=='video'){ | |
//print video | |
$video_url = pexeto_get_single_meta( $p->ID, 'video' ); | |
if ( $video_url ) { | |
$html.=pexeto_get_video_html( $video_url, $img_size['width'] ); | |
$has_header = true; | |
} | |
}elseif($format=='gallery'){ | |
//print Nivo slider | |
$images = pexeto_get_nivo_post_images($p, $img_size); | |
$options = pexeto_get_nivo_args('_post'); | |
$slider_div_id = 'post-gallery-'.$p->ID.pexeto_generate_nivo_id(); | |
$html.=pexeto_get_nivo_slider_html($images, $options, $slider_div_id, $img_size['height'], $img_size['crop']); | |
$has_header = true; | |
}elseif(has_post_thumbnail($p->ID)){ | |
//print thumbnail image | |
$thumb_id = get_post_thumbnail_id( $p->ID ); | |
$thumb_url = wp_get_attachment_image_src( $thumb_id, 'home-thumbnail', true ); | |
$image = $thumb_url[0]; | |
$html.=sprintf('<a href="%s"><img src="%s" ></a>', | |
get_permalink( $p->ID), | |
$thumb_url[0]); | |
$has_header = true; | |
} | |
$html.='</div>'; | |
} | |
if(!in_array($format, array('quote', 'aside'))){ | |
if(!$has_header){ | |
$html.='<div class="rp-no-header">'; | |
} | |
//print title and excerpt | |
$html.=sprintf('<h4 class="rp-post-title"><a href="%s">%s</a></h4>', get_permalink( $p->ID ), $p->post_title); | |
if($show_content){ | |
$excerpt = !empty($p->post_excerpt) ? $p->post_excerpt : get_the_excerpt($p->ID); | |
$html.=sprintf('<p>%s</p>', $excerpt); | |
//add a read more link | |
$html.=sprintf('<a class="read-more" href="%s">%s <span class="more-arrow">›</span></a>', | |
get_permalink( $p->ID ), | |
__('Read More', 'pexeto')); | |
} | |
if(!$has_header){ | |
$html.='</div>'; | |
} | |
}else{ | |
if($format=='quote'){ | |
//print quote | |
$html.=sprintf('<div class="format-quote"><blockquote>%s</blockquote></div>', $p->post_content); | |
}else{ | |
//print aside | |
$html.=sprintf('<div class="format-aside"><aside><p>%s</p></aside></div>', $p->post_content); | |
} | |
} | |
$html.='</div>'; //close rp div | |
if($i%$columns==$columns-1){ | |
$html.='</div>'; //close cols wrapper div | |
$opened = false; | |
} | |
} | |
if(isset($opened) && $opened){ | |
$html.='</div>'; //close cols wrapper div | |
} | |
return $html; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment