Created
May 21, 2015 20:41
-
-
Save pingram3541/3bcdb9c575f5831e20dc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Template Name: Specials | |
* | |
* @package Betheme | |
* @author Muffin Group | |
*/ | |
get_header(); | |
function get_ID_by_slug($page_slug) { | |
$page = get_page_by_path($page_slug); | |
if ($page) { | |
return $page->ID; | |
} | |
else { | |
return null; | |
} | |
} | |
$postid = get_ID_by_slug('specials'); //get id of my specials page | |
$sidebars = mfn_opts_get( 'sidebars' ); | |
$key = array_search('specials', $sidebars); //stores sidebar from page muffin options | |
$cat_uncatagorized = get_category_by_slug('uncategorized'); | |
$cat_uncatagorized_id = $cat_uncatagorized->term_id; //id of uncategorized category | |
$cat_upholstery = get_category_by_slug('upholstery'); | |
$cat_upholstery_id = $cat_upholstery->term_id; //cat id of upholstery category | |
$cat_carpet_cleaning = get_category_by_slug('carpet-cleaning'); | |
$cat_carpet_cleaning_id = $cat_carpet_cleaning->term_id; //id of carper-cleaning category | |
$cat_tile_stone_grout = get_category_by_slug('tile-stone-grout'); | |
$cat_tile_stone_grout_id = $cat_tile_stone_grout->term_id; //id of tile-stone-grout category | |
?> | |
<div id="print"></div> | |
<div id="Content"> | |
<div class="content_wrapper clearfix"> | |
<div class="sections_group"> | |
<div class="section specials"> | |
<div class="section_wrapper clearfix"> | |
<?php | |
if( have_posts() ){ | |
the_post(); | |
} | |
$i_up = $i_cc = $i_tsg = 0; | |
?> | |
<div class="sections_group" style="margin-top: 35px;"> | |
<div class="one-fourth column sidebar"> | |
<?php dynamic_sidebar( $sidebars[$key] ); ?> | |
</div> | |
<div class="three-fourth column specials-wrapper"> | |
<h4 style="text-align: center;"><?php _e('Available specials and promotions.','betheme'); ?></h4> | |
<?php | |
$args = array( | |
'post_type' => array('specials'), | |
'posts_per_page' => 99, | |
'order' => 'ASC' | |
); | |
$posts_query = new WP_Query( $args ); | |
while ($posts_query->have_posts()) : $posts_query->the_post(); | |
$categories = get_the_category(); | |
foreach($categories as $category){ | |
if ($category->term_id == $cat_upholstery_id){ | |
$i_up++; | |
if($i_up == 1){ | |
?> | |
<h5 class="cat-title">Upholstery Specials</h5> | |
<?php | |
} ?> | |
<div class="special"> | |
<!-- detail for <?php the_title(); ?> --> | |
<img src="/wp-content/uploads/chem-dry-logo-sm.png" /> | |
<h2><?php the_field('special_discount'); ?></h2> | |
<h5><?php the_field('special_text'); ?></h5> | |
<p><?php the_field('special_terms'); ?></p> | |
<input type="button" class="printme" value="Print Me"/> | |
</div> | |
<?php | |
} else if ($category->term_id == $cat_carpet_cleaning_id){ | |
$i_cc++; | |
if($i_cc == 1){ | |
?> | |
<h5 class="cat-title">Carpet Cleaning Specials</h5> | |
<?php | |
} ?> | |
<div class="special"> | |
<!-- detail for <?php the_title(); ?> --> | |
<img src="/wp-content/uploads/chem-dry-logo-sm.png" /> | |
<h2><?php the_field('special_discount'); ?></h2> | |
<h5><?php the_field('special_text'); ?></h5> | |
<p><?php the_field('special_terms'); ?></p> | |
<input type="button" class="printme" value="Print Me"/> | |
</div> | |
<?php | |
} else if ($category->term_id == $cat_tile_stone_grout_id){ | |
$i_tsg++; | |
if($i_tsg == 1){ | |
?> | |
<h5 class="cat-title">Tile, Stone & Grout Cleaning Specials</h5> | |
<?php | |
} ?> | |
<div class="special"> | |
<!-- detail for <?php the_title(); ?> --> | |
<img src="/wp-content/uploads/chem-dry-logo-sm.png" /> | |
<h2><?php the_field('special_discount'); ?></h2> | |
<h5><?php the_field('special_text'); ?></h5> | |
<p><?php the_field('special_terms'); ?></p> | |
<input type="button" class="printme" value="Print Me"/> | |
</div> | |
<?php | |
} else { | |
} | |
} | |
endwhile; wp_reset_query(); ?> | |
</div> | |
</div> <!-- close section group --> | |
</div> <!-- close section wrapper --> | |
</div> <!-- close section --> | |
</div> <!-- close section group --> | |
<?php | |
mfn_builder_print( $postid ); // Content Builder & WordPress Editor Content | |
?> | |
</div> | |
</div> | |
<script> | |
(function($){ | |
function clearprintables(){ | |
$("#print").html(""); | |
} | |
function printme(){ | |
window.print(); | |
} | |
$(".printme").on('click', function(){ | |
clearprintables(); | |
$(this).closest('.special').clone().appendTo("#print"); | |
printme(); | |
}); | |
})(jQuery); | |
</script> | |
<?php get_footer(); ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment