Skip to content

Instantly share code, notes, and snippets.

@mustafix
Last active March 30, 2017 13:18
Show Gist options
  • Save mustafix/ed86d40147ab8a9846fa460585ff383c to your computer and use it in GitHub Desktop.
Save mustafix/ed86d40147ab8a9846fa460585ff383c to your computer and use it in GitHub Desktop.
<?php
// function.php
function double_shortcode($atts, $content = null){
extract( shortcode_atts( array(
'category' => '',
'count' => '',
'title' => '',
'des' => '',
), $atts ) );
$q = new WP_Query(
array(
'posts_per_page' => $count,
'post_type' => 'portfolio',
'portfolio_category' =>$category ,
//'meta_key'=> 'order_number',
'order' => 'ASC',
'orderby' => 'title',
));
$list = '
<section id="content">
<div class="container">
<div class="row">
<div class="col-lg-12">
<h4 class="heading">'.$title.'</h4>
<p class="content">'.$des.'</p>
<div class="row">
<section id="projects">
<ul id="thumbs" class="portfolio">
';
while($q->have_posts()) : $q->the_post();
$idd = get_the_ID();
$portfolio_thumb = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'portfolio-thumb' );
$portfolio_large = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'large' );
$variable = get_post_meta($idd, 'variable', true);
$list .= '
<li class="col-lg-3 design" data-id="id-0" data-type="web">
<div class="item-thumbs">
<a class="hover-wrap fancybox" data-fancybox-group="gallery" title="'.get_the_title().'" href="'.$portfolio_large[0].'">
<span class="overlay-img"></span>
<span class="overlay-img-thumb font-icon-plus"></span>
</a>
<div class="icon">
<i>fa-fa- '.$variable.' ?></i>
</div>
<img src="'.$portfolio_thumb[0].'" alt="'.get_the_excerpt().'">
</div>
</li>
';
endwhile;
$list.= '
</ul>
</section>
</div>
</div>
</div>
</div>
</section>
';
wp_reset_query();
return $list;
}
add_shortcode('d_shortcode', 'double_shortcode');
?>
<?php
//index.php
echo do_shortcode('[d_shortcode title="" des="" count="" category=""]');
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment