Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- function wishlist_shortcode($atts){
- extract( shortcode_atts( array(
- 'cat' => '',
- ), $atts, 'wishlist' ) );
- $q = new WP_Query(
- array('posts_per_page' => '4', 'post_type' => 'wishlist-items', 'category_name' => $cat, 'meta_key' => 'order_number','orderby' => 'meta_value','order' => 'ASC')
- );
- $list = '<div class="wishlist_item_list">';
- while($q->have_posts()) : $q->the_post();
- $idd = get_the_ID();
- $wishlist_email = get_post_meta($idd, 'wishlist_email', true);
- $featured_image_url = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'case-study-image' );
- $theme_dir = get_bloginfo('template_directory');
- $item_cats = get_the_terms($post->ID, 'category_name');
- if($item_cats):
- foreach($item_cats as $item_cat) {
- $item_classes = $item_cat->name ;
- }
- endif;
- $list .= '
- <div class="single_wishlist">
- <p>Category Name: '.$item_classes.'</p>
- <div class="wishlist_top">
- <p>'.get_the_title().'<a href="'.get_the_permalink().'">'.$wishlist_email.'</a></p>
- </div>
- <img src="'.$featured_image_url[0].'" alt="" />
- <img src="'.$theme_dir.'/img/link_style.png" alt="" />
- <div class="wishlist_bottom">
- ' .get_the_excerpt(). '
- </div>
- </div>
- ';
- endwhile;
- $list.= '</div>';
- wp_reset_query();
- return $list;
- }
- add_shortcode('wishlist', 'wishlist_shortcode');
- // another way for custom post
- function page_item_shortcode($atts){
- ob_start();
- extract( shortcode_atts( array(
- 'cat' => '',
- 'count' => -1,
- ), $atts, 'page_item' ) );
- $q = new WP_Query(
- array('posts_per_page' => $count, 'post_type' => 'post', 'category_name' => $cat, )
- );
- ?>
- <?php while( $q->have_posts()) : $q->the_post(); ?>
- <div class="homepage_box_one">
- <div class="main_feature_image box_inner" style="background-image: url(<?php $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), '' ); echo $image[0]; ?>); -ms-background-position-x: center; -ms-background-position-y: center; background-position: center bottom; background-size: cover;">
- <div class="box_overlay"></div>
- <div class="box_date"><?php the_time('Y.m.d') ?><br />/<br />by <?php the_author(); ?></div>
- <i class="fm_icon box_icon">5</i>
- <div class="box_text text-center">
- <h1><?php the_title(); ?></h1>
- </div>
- <div class="box_excerpt"><?php $post_content = get_the_content(); echo wp_trim_words($post_content, 30 );?></div>
- </div>
- <a class="box_button_link" href="<?php the_permalink(); ?>"><?php $categories = get_the_category();
- if ( ! empty( $categories ) ) {
- echo esc_html( $categories[0]->name );
- }?></a>
- </div>
- <?php endwhile; ?>
- <?php wp_reset_postdata();
- return ob_get_clean();
- }
- add_shortcode('page_item', 'page_item_shortcode');
- /* shorcode for attraction widget */
- function attraction_item_shortcode($atts){
- ob_start();
- extract( shortcode_atts(
- array(
- 'id' => '',
- ), $atts, 'attraction' ) );
- $myarray = explode(',', $id);
- $q = new WP_Query(
- array('posts_per_page' => -1, 'post_type' => 'attractions-items', 'post__in'=> $myarray
- ));
- while( $q->have_posts()) : $q->the_post(); ?>
- <div class="field-images">
- <a href="<?php the_permalink();?>">
- <img class="high" src="<?php $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'widget-image' ); echo $image[0]; ?>" alt=""/>
- <h5><?php the_title();?></h5>
- </a>
- </div>
- <?php endwhile; ?>
- <?php wp_reset_postdata(); return ob_get_clean();
- }
- add_shortcode('attraction', 'attraction_item_shortcode');
- // do shorcode example start
- function product_shortcode( $atts, $content = null ) {
- return '
- <div class="post_page_slider_social_area fix">
- <div class="post_page_slider_social column fix">
- <div class="post_page_slider_social_wrapper fix">
- <div class="post_content_slider section fix">
- <div class="sc_single_content_slider owl-carousel fix" id="sc_single_content_slider">
- '.do_shortcode($content).'
- </div>
- </div>
- </div>
- </div>
- </div>
- ';
- }
- add_shortcode('product', 'product_shortcode');
- function product_item_shortcode( $atts, $content = null ) {
- extract( shortcode_atts( array(
- 'src' => '',
- 'title' => '',
- ), $atts ) );
- return '
- <div class="item scscs_single">
- <img src="'.$src.'" alt="'.$title.'" />
- </div>
- ';
- }
- add_shortcode('item', 'product_item_shortcode');
- // do shorcode example end
- function core_list_shortcode( $atts, $content = null ) {
- extract( shortcode_atts( array(
- 'id' => '',
- ), $atts ) );
- return 'jQuery("#codeapp'.$id.'").show();';
- }
- add_shortcode('core', 'core_list_shortcode');
- function column_shortcode( $atts, $content = null ) {
- return '<div class="column_content">'.do_shortcode($content).'</div>';
- }
- add_shortcode('col', 'column_shortcode');
- ?>
Advertisement
Add Comment
Please, Sign In to add comment