Site icon Hip-Hop Website Design and Development

get class in listing of posts // shortcode for customized associated posts

i’m searching for an answer to get the class of the associated publish. I created a shortcode (@buttered_toast helped me, thanks for that) that may be inserted in a publish. This exhibits customized IDs/posts. It really works high-quality, however sadly it doesn’t present the related (most important)class of every publish. In all makes an attempt, solely "array" was output or the class of the publish during which the shortcode is inserted.

operate posts_shortcode($atts) {
    
    $atts = shortcode_atts( array(
        'id' => ''
    ), $atts );
    
    $html  = '<div class="posts">';

    foreach (explode(',', $atts['id']) as $post_id) {

        $html .= '<div class="post">';
        $html .= '<div class="thumb">' . get_the_post_thumbnail($post_id, 'medium') . '</div>';
        $html .= '<span class="badge">' . CATEGORY HERE . '</span>';
        $html .= '<div class="content">';
        $html .= '<h4>' . get_the_title($post_id) . '</h4>';
        $html .= '<p>' . get_the_excerpt($post_id) . '</p>';
        $html .= '</div>';
        $html .= '</div>';
    }

    $html .= '</div>';
    
    return $html; 
}

I feel its straightforward for you guys, however i dont have any thought anymore…