// add shortcode for the landing page blocks
function landing_page_blocks( $atts )
{
+ $out = '';
extract(shortcode_atts(
array('category' => '-1'), $atts, 'glm-blocks')
);
if(function_exists('fetch_all_glm_blocks')):
$category = filter_var($atts['category'], FILTER_VALIDATE_INT);
$blocks = fetch_all_glm_blocks($category);
- echo '<ul id="quick-sub_pages" class="small-block-grid-1 medium-block-grid-3">';
+ $out .= '<ul id="quick-sub_pages" class="small-block-grid-1 medium-block-grid-3">';
foreach ($blocks as $block):
$post_image_id = get_post_thumbnail_id($block->ID);
$thumbnail = wp_get_attachment_image_src( $post_image_id, 'landing_page');
- echo '<li class="small-text-center medium-text-left landing-item">';
+ $out .= '<li class="small-text-center medium-text-left landing-item">';
if($block->url):
- echo '<a href="'.$block->url.'"'.(($block->externalUrl)? ' target="_blank"':'').'>';
+ $out .= '<a href="'.$block->url.'"'.(($block->externalUrl)? ' target="_blank"':'').'>';
endif;
- echo '<img src="'.$thumbnail[0].'"/>';
- echo '<h5>'.$block->post_title.'</h5>';
+ $out .= '<img src="'.$thumbnail[0].'"/>';
+ $out .= '<h5>'.$block->post_title.'</h5>';
if($block->url):
- echo '</a>';
+ $out .= '</a>';
endif;
- echo '</li>';
+ $out .= '</li>';
endforeach;
- echo '</ul>';
+ $out .= '</ul>';
endif;
+ return $out;
}
add_shortcode('glm-blocks', 'landing_page_blocks');
?>