Skip to content

Instantly share code, notes, and snippets.

@coder618
Last active December 7, 2019 02:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save coder618/9228d07b7653d27e4978c051202e4e91 to your computer and use it in GitHub Desktop.
Save coder618/9228d07b7653d27e4978c051202e4e91 to your computer and use it in GitHub Desktop.
Render Posts , template for: post type
// following function will be use when you apply this shortcode: [render-posts type="post"]
function post_template($id){
$c_id = $id;
$post_img_url = get_the_post_thumbnail_url($c_id, 'large');
$title = esc_html(get_the_title($c_id));
$html = '';
$html .= '<a href="'.get_permalink($c_id).'" class="default-post-template">';
if($post_img_url):
$html .= '<img src="'.$post_img_url.'" alt="'.$title.'">';
endif;
$html .= '<div class="text-section">';
$html .= '<h3 class="title">'.$title.'</h3>';
$html .= '<p>'.get_the_excerpt($c_id).'</p>';
$html .= '</div>';
$html .= '</a>';
return $html;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment