Last active
December 7, 2019 02:58
-
-
Save coder618/9228d07b7653d27e4978c051202e4e91 to your computer and use it in GitHub Desktop.
Render Posts , template for: post type
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
// 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