$selectedCategories, 'posts_per_page' => 'true' == $postsPerPageAll ? -1 : $postsPerPage, 'orderby' => $postsOrderBy, 'order' => $postsOrder, ] ); $alignClass = '' == $align ? '' : 'align' . $align; ob_start(); echo '
'; if ( 'grid' == $layout ) { echo '
'; foreach ( $posts as $post ) { $contentHeight = 'true' == $contentEqualHight ? "100%" : "auto"; echo '
' . bBlocksPostFeatureImg( $featureImgShow, $post ) . '
' . bBlocksPostTitle( $titleShow, $post, $contentAlign, $titleFontSize, $titleColor, $titleMB ) . bBlocksPostMetaData( $metaShow, $post, $metaAuthorShow, $metaDateShow, $metaCategoryShow, $metaCommentShow, $contentAlign, $metaFontSize, $metaTransform, $metaTextColor, $metaLinkColor, $metaIconColor, $metaMB ) . bBlocksPostExcerpt( $excerptShow, $post, $excerptAlign, $excerptFontSize, $excerptColor, $excerptMB, $excerptLength ) . bBlocksPostReadMore( $readMoreShow, $post, $readMoreAlign, $readMoreFontSize, $readMoreTransform, $readMoreFontWeight, $readMoreColor, $readMoreHovColor, $readMoreLabel ) . '
'; } echo '
'; } else if ( 'masonry' == $layout ) { echo '
'; foreach ( $posts as $post ) { echo '
' . bBlocksPostFeatureImg( $featureImgShow, $post ) . '
' . bBlocksPostTitle( $titleShow, $post, $contentAlign, $titleFontSize, $titleColor, $titleMB ) . bBlocksPostMetaData( $metaShow, $post, $metaAuthorShow, $metaDateShow, $metaCategoryShow, $metaCommentShow, $contentAlign, $metaFontSize, $metaTransform, $metaTextColor, $metaLinkColor, $metaIconColor, $metaMB ) . bBlocksPostExcerpt( $excerptShow, $post, $excerptAlign, $excerptFontSize, $excerptColor, $excerptMB, $excerptLength ) . bBlocksPostReadMore( $readMoreShow, $post, $readMoreAlign, $readMoreFontSize, $readMoreTransform, $readMoreFontWeight, $readMoreColor, $readMoreHovColor, $readMoreLabel ) . '
'; } echo '
'; } else { echo ''; } echo '
'; return ob_get_clean(); } // Components // Feature Image function bBlocksPostFeatureImg( $show, $post ) { if ( 'true' == $show ) { return '
' . get_the_post_thumbnail( $post->ID ) . '
'; } else { return ''; } } // Title function bBlocksPostTitle( $show, $post, $align, $fontSize, $color, $mb ) { if ( 'true' == $show ) { return '

' . $post->post_title . '

'; } else { return ''; } } // Meta Data function bBlocksPostMetaData( $show, $post, $authorShow, $dateShow, $categoryShow, $commentShow, $align, $fontSize, $transform, $textColor, $linkColor, $iconColor, $mb ) { if ( 'true' == $show ) { return '

' . bBlocksPostMetaAuthor( $authorShow, $post, $iconColor, $linkColor ) . bBlocksPostMetaDate( $dateShow, $post, $iconColor, $textColor ) . bBlocksPostMetaCategory( $categoryShow, $post, $iconColor, $linkColor ) . bBlocksPostMetaComment( $commentShow, $post, $iconColor, $linkColor ) . '

'; } else { return ''; } } function bBlocksPostMetaAuthor( $show, $post, $iconColor, $linkColor ) { if ( 'true' == $show ) { return '   ' . get_the_author_posts_link( $post->ID ) . ' '; } else { return ''; } } function bBlocksPostMetaDate( $show, $post, $iconColor, $textColor ) { if ( 'true' == $show ) { return '   ' . get_the_date( 'M j, Y', $post->ID ) . ' '; } else { return ''; } } function bBlocksPostMetaCategory( $show, $post, $iconColor, $linkColor ) { if ( 'true' == $show ) { return '   ' . get_the_category_list( ', ', '', $post->ID ) . ' '; } else { return ''; } } function bBlocksPostMetaComment( $show, $post, $iconColor, $linkColor ) { if ( 'true' == $show ) { $comment_count = get_comments( array( 'post_id' => $post->ID, 'count' => true ) ); $view_comment = ''; switch ( $comment_count ) { case "0": $view_comment = esc_html__( 'No Comments', 'b-blocks' ); break; case "1": $view_comment = esc_html__( '1 Comment', 'b-blocks' ); break; default: $view_comment = esc_html__( "$comment_count Comments", 'b-blocks' ); } return '   ' . $view_comment . ' '; } else { return ''; } } // Excerpt function bBlocksPostExcerpt( $show, $post, $align, $fontSize, $color, $mb, $length ) { if ( 'true' == $show ) { return '
' . implode( ' ', array_slice( explode( ' ', get_post_field( 'post_content', $post->ID ) ), 0, $length ) ) . '
'; } else { return ''; } } // Read More function bBlocksPostReadMore( $show, $post, $align, $fontSize, $transform, $fontWeight, $color, $hovColor, $label ) { if ( 'true' == $show ) { return '
' . $label . '
'; } else { return ''; } }