Skip to content

Instantly share code, notes, and snippets.

@shahadat014
Created February 16, 2015 11:26
Show Gist options
  • Select an option

  • Save shahadat014/7defd98ea22d18a598dc to your computer and use it in GitHub Desktop.

Select an option

Save shahadat014/7defd98ea22d18a598dc to your computer and use it in GitHub Desktop.
text shortcode into custompost
function test_shortcode($atts, $content = null){
extract( shortcode_atts( array(
'expand' => '',
), $atts) );
$q = new WP_Query(
array('posts_per_page' =>'9', 'post_type' =>'service')
);
$list = '<article class="widget-mini left-icon" >';
while($q->have_posts()) : $q->the_post();
$idd = get_the_ID();
$icon_type = get_post_meta($idd, 'icon_type', true);
$list .= '<div class="widget-mini-contents">
<div class="widget-mini-feature-image">
<i class="icon-'.$icon_type.'"></i>
</div>
<div class="feature-heading">
<h4><a href="'.get_permalink().'">'.get_the_title().'</a></h4>
</div>
<div class="widget-mini-desc">
' .do_shortcode( get_the_content() ). '
</div>
</div>
';
endwhile;
$list.= '</article>';
wp_reset_query();
return $list;
}
add_shortcode('list', 'test_shortcode');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment