Skip to content

Instantly share code, notes, and snippets.

@asadaly111
Last active July 19, 2017 15:08
Show Gist options
  • Save asadaly111/d83d890b6f5fbcbd02415e37c251ee31 to your computer and use it in GitHub Desktop.
Save asadaly111/d83d890b6f5fbcbd02415e37c251ee31 to your computer and use it in GitHub Desktop.
farhanCustomFile woocommerce shortcode
function woocommerce_video_shortcode( $atts ) {
$args = array( 'post_type' => 'all_video', 'posts_per_page' => 10, 'orderby' => 'title','order' => 'desc' );
$loop = new WP_Query( $args );
$posts = $loop->posts;
echo '<div class="flexslider"><ul class="slides">';
foreach($posts as $key => $the_query)
{ ?>
<li>
<div class="nectar-video-box" data-color="default-accent-color" data-shadow="none">
<a href="<?php echo $the_query->post_title; ?>" class="full-link" rel="prettyPhoto"></a>
<img width="1600" height="515" src="<?php echo wp_get_attachment_url( get_post_thumbnail_id($the_query->ID)); ?>" class="attachment-full size-full" alt="" srcset="<?php echo wp_get_attachment_url( get_post_thumbnail_id($the_query->ID)); ?> 1600w, <?php echo wp_get_attachment_url( get_post_thumbnail_id($the_query->ID)); ?> 300w, <?php echo wp_get_attachment_url( get_post_thumbnail_id($the_query->ID)); ?> 1024w" sizes="(max-width: 1600px) 100vw, 1600px">
<a href="<?php echo $the_query->post_title; ?>" data-color="default" class="play_button_2 large nectar_video_lightbox" rel="prettyPhoto"><span>
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="600px" height="800px" x="0px" y="0px" viewBox="0 0 600 800" enable-background="new 0 0 600 800" xml:space="preserve">
<path fill="none" d="M0-1.79v800L600,395L0-1.79z"></path></svg></span></a>
</div>
</li>
<?php }
echo '</ul></div>';
//echo "<pre>";
//print_r($query);
//exit;
return;
}
add_shortcode( 'woocommerce_video_products', 'woocommerce_video_shortcode');
function woocommerce_featuredz_shortcode( $atts ) {
//echo "THis is test Ahsan";
// $args = array( 'post_type' => 'product', 'posts_per_page' => 10, 'orderby' => 'title','order' => 'desc' );
// $loop = new WP_Query( $args );
// $posts = $loop->posts;
// echo '<div class="flexslider"><ul class="slides">';
//foreach($posts as $key => $the_query)
// { // ?>
<!-- <li>
<div class="vc_col-sm-4"><img src="<?php // echo wp_get_attachment_url( get_post_thumbnail_id($the_query->ID)); ?>" /></div>
<div class="vc_col-sm-7">
<h3 class="left_space"><a href="<?php // echo $the_query->guid; ?>"><?php // echo $the_query->post_title; ?></a></h3> -->
<?php// $content = $the_query->post_content; $trimmed_content = wp_trim_words( $content, 150, ' <a href="'.$the_query->guid.'"> More Info </a>' ); ?>
<?php// echo $trimmed_content; ?>
<?php // $mycontent = $the_query->post_excerpt; $trimmed_contentz = wp_trim_words( $mycontent, 70, ' ' ); ?>
<!-- <p class="left_space praclass"><?php // echo $trimmed_contentz; ?></p> -->
<!-- <div class="clear"></div>
</div>
</li> -->
<?php // }
//echo '</ul></div>';
//echo "<pre>";
//print_r($query);
//exit;
return;
}
add_shortcode( 'woocommerce_featured_products', 'woocommerce_featuredz_shortcode');
function woocommerce_vc_shortcode( $atts ) {
//return;
$args = array( 'post_type' => 'product', 'posts_per_page' => 5, 'orderby' => 'date', 'product_cat' => 'safe-ladder','orderby' => 'date' );
$loop = new WP_Query( $args );
$posts = $loop->posts;
// echo "<pre>";
// print_r($posts);
//exit;
foreach($posts as $key => $the_query)
{ ?>
<div class="vc_col-sm-3 wpb_column column_container vc_column_container col">
<img src="<?php echo wp_get_attachment_url( get_post_thumbnail_id($the_query->ID)); ?>" />
<a class="montsemi" href="<?php echo $the_query->guid; ?>"><?php echo $the_query->post_title; ?></a>
<?php $content=$the_query->post_excerpt; $trimmed_content = wp_trim_words( $content, 6, '' ); ?>
<p class="box1z"><?php echo get_field('shortdec', $the_query->ID); ?><?php // echo $trimmed_content; ?></p>
<a class="mypra" href="<?php echo $the_query->guid; ?>">More Info </a>
<?php
//echo "<pre>";
//print_r($the_query); ?>
<div class="clear"></div>
</div>
<?php }
return;
}
add_shortcode( 'woocommerce_output', 'woocommerce_vc_shortcode');
function woocommerce_easi_dec_shortcode( $atts ) {
//return;
$args = array( 'post_type' => 'product', 'posts_per_page' => 5, 'orderby' => 'date', 'product_cat' => 'easi-dec', 'orderby' => 'date' );
$loop = new WP_Query( $args );
$posts = $loop->posts;
//echo "<pre>";
//print_r($posts);
//exit;
foreach($posts as $key => $the_query)
{ ?>
<div class="vc_col-sm-3 wpb_column column_container vc_column_container col mybox11 one-fourths">
<img src="<?php echo wp_get_attachment_url( get_post_thumbnail_id($the_query->ID)); ?>" />
<a class="montsemi2" href="<?php echo $the_query->guid; ?>"><?php echo $the_query->post_title; ?></a>
<?php // $content=$the_query->post_content; $trimmed_content = wp_trim_words( $content, 35, ' <a class="mypra" href="'.$the_query->guid.'"> More Info </a>' ); ?>
<?php $content=$the_query->post_excerpt; $trimmed_content = wp_trim_words( $content, 4, '' ); ?>
<p class="box2z"><?php echo get_field('shortdec', $the_query->ID); ?><?php // echo $trimmed_content; ?></p>
<!-- <p class="box2z"><?php // echo $trimmed_content; ?></p> -->
<a class="mypra" href="<?php echo $the_query->guid; ?>">More Info </a>
<div class="clear"></div>
</div>
<?php }
return;
}
add_shortcode( 'woocommerce_easi_dec', 'woocommerce_easi_dec_shortcode');
function woocommerce_roof_shortcode( $atts ) {
//return;
$args = array( 'post_type' => 'product', 'posts_per_page' => 5, 'orderby' => 'date', 'product_cat' => 'roof-railings', 'orderby' => 'date' );
$loop = new WP_Query( $args );
$posts = $loop->posts;
//echo "<pre>";
//print_r($posts);
//exit;
foreach($posts as $key => $the_query)
{ ?>
<div class="vc_col-sm-3 wpb_column column_container vc_column_container col mybox11 one-fourths">
<img src="<?php echo wp_get_attachment_url( get_post_thumbnail_id($the_query->ID)); ?>" />
<a class="montsemi2" href="<?php echo $the_query->guid; ?>"><?php echo $the_query->post_title; ?></a>
<?php // $content=$the_query->post_content; $trimmed_content = wp_trim_words( $content, 35, ' <a class="mypra" href="'.$the_query->guid.'"> More Info </a>' ); ?>
<?php $content=$the_query->post_excerpt; $trimmed_content = wp_trim_words( $content, 4, '' ); ?>
<!-- <p class="box2z"><?php // echo $trimmed_content; ?></p> -->
<p class="box2z"><?php echo get_field('shortdec', $the_query->ID); ?><?php // echo $trimmed_content; ?></p>
<a class="mypra" href="<?php echo $the_query->guid; ?>">More Info </a>
<div class="clear"></div>
</div>
<?php }
return;
}
add_shortcode( 'woocommerce_roof', 'woocommerce_roof_shortcode');
function my_post_shortcode( $atts ) {
//$the_query = new WP_Query( array('posts_per_page' => 5, 'post_type' => 'post_demo', 'paged' => $paged,'order'=>'DESC',) );
$the_query = new WP_Query( array('posts_per_page' => 2,'post_type' => 'post','order'=>'DESC','tax_query' => array( array('taxonomy' => 'category', 'field' => 'id', 'terms' => 61, ),), ));
$posts = $the_query->posts;
//echo "<pre>";
//print_r($posts);
//exit;
foreach($posts as $key => $the_query)
{ ?>
<div class="vc_col-sm-3 blogbox">
<img src="<?php echo $feat_image = wp_get_attachment_url( get_post_thumbnail_id($the_query->ID) ); ?>" alt="">
<a class="montsemiz" href="<?php echo $the_query->guid; ?>"><?php echo $the_query->post_title; ?></a>
<?php $content = $the_query->post_content; $trimmed_content = wp_trim_words( $content, 20, '' ); ?>
<p><?php echo $trimmed_content; ?></p>
<a class="last_blog" href=" <?php echo $the_query->guid; ?>">More Info</a>
</div>
<?php }
return;
}
add_shortcode( 'blog_post_shortcode', 'my_post_shortcode');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment