Advertisement
Guest User

Untitled

a guest
Jul 11th, 2014
44
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.15 KB | None | 0 0
  1. <!--product dropdown-->
  2. <?php
  3. //$hd_var=$_POST['hidden_prod'];
  4.  
  5. $dpwn = array(
  6. 'post_type' => 'product',
  7. 'paged' => $paged,
  8. 'orderby'=>'title','posts_per_page'=> -1,
  9. 'order'=>'ASC', 'tax_query' => array(
  10. array(
  11. 'taxonomy' => 'product_cat',
  12. 'field' => 'slug',
  13. 'terms' => 'products'
  14. )
  15. )
  16. );
  17. $search_drpdwn=new WP_Query($dpwn);
  18. ?>
  19. <?php wp_reset_postdata();?>
  20. <div class="styled-select">
  21. <form method="post" action="" id="prod_form">
  22. <select id="product_post" name="product_post">
  23. <!--onchange="window.location.replace(this.options[this.selectedIndex].value)"-->
  24. <option>Select Product</option>
  25. <?php while($search_drpdwn->have_posts()): $search_drpdwn->the_post();?>
  26. <option value="<?php echo $post->ID;?>" ><?php the_title();?></option>
  27. <?php endwhile;?>
  28. </select>
  29. <input type="hidden" name="hidden_prod" id="hidden_prod" value="">
  30. </form>
  31. </div></div>
  32. <?php
  33. if(isset($_POST['product_post']))
  34. {
  35. $hd_var=$_POST['hidden_prod'];
  36.  
  37. $drpwn = array(
  38. 'post_type' => 'products',
  39. 'paged' => $paged,
  40. 'orderby'=>'title',
  41. 'order'=>'ASC',
  42. 'p'=>$hd_var
  43. );
  44. $s_drpdwn=new WP_Query($drpwn);
  45. ?>
  46. <!--<form method="post" action="">-->
  47. <?php
  48. if($s_drpdwn->have_posts()) :
  49. while($s_drpdwn->have_posts()): $s_drpdwn->the_post();?>
  50. <div class="prd-sec">
  51. <?php $tet= get_post_meta( get_the_ID(), 'wpcf-game-instructions', true );
  52. if($tet == '')
  53. {
  54. ?>
  55.  
  56. <a href="#" class="product-thump-img"><?php the_post_thumbnail('blog-small');?></a>
  57. <?php
  58. echo "<b>".the_title()."</b> : No Instruction PDF Found";
  59. }
  60. else
  61. {
  62. ?>
  63. <a href="<?php echo get_post_meta( get_the_ID(), 'wpcf-game-instructions', true ) ?>" class="product-thump-img"><?php the_post_thumbnail('blog-small');?></a>
  64. <a href="<?php echo get_post_meta( get_the_ID(), 'wpcf-game-instructions', true ) ?>"><?php the_title();?> Instructions</a>
  65.  
  66. <?php
  67. }
  68. ?>
  69. </div>
  70. <?php endwhile;
  71. else:
  72. ?>
  73. <p style="color:red">No Instructions Found</p>
  74. <?php
  75. endif;
  76. ?>
  77. <?php } ?>
  78. <!--</form>-->
  79.  
  80. <!-- Product Search-->
  81. <?php
  82. if(is_front_page()) {
  83. $paged = (get_query_var('page')) ? get_query_var('page') : 1;
  84. } else {
  85. $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
  86. }
  87. if(isset($_POST['submit']))
  88. {
  89. //global $wpdb;
  90. $keywd=$_POST['user'];
  91. if(is_numeric($keywd))
  92. {
  93. /*$str="select p.* from $wpdb->posts p,$wpdb->postmeta pm where p.ID = pm.post_id and
  94. //p.ID IN (SELECT post_id FROM wp_postmeta WHERE meta_key = 'Item' AND meta_value = $keywd)";*/
  95. $str="select m.post_id from $wpdb->postmeta m where (m.meta_key='wpcf-item' and m.meta_value LIKE $keywd) OR (m.meta_key='wpcf-ean-upc-number' and m.meta_value LIKE $keywd) OR (m.meta_key='EAN-UPC Number' and m.meta_value LIKE $keywd)";
  96. $result = $wpdb->get_results($str,OBJECT);
  97. //echo $str;
  98. //print_r($result);
  99. foreach($result as $post)
  100. {
  101. $postid = $post->post_id;
  102. $ret=get_post_meta( $postid, 'wpcf-game-instructions', true );
  103. if($ret == '')
  104. {
  105. ?>
  106.  
  107. <a href="#" class="product-thump-img"><?php echo get_the_post_thumbnail($postid, 'blog-small');?></a>
  108. <?php
  109. echo "<b>".get_the_title($postid)."</b> : No Instruction PDF Found";
  110. }
  111. else
  112. {
  113. ?>
  114. <a href="<?php echo get_post_meta( $postid, 'wpcf-game-instructions', true ) ?>" class="product-thump-img"><?php echo get_the_post_thumbnail($postid, 'blog-small');?></a>
  115. <a href="<?php echo get_post_meta( $postid, 'wpcf-game-instructions', true ) ?>"><?php echo get_the_title($postid);?> Instructions</a>
  116. <?php
  117. }
  118. }
  119. }
  120. else
  121. {
  122. $args = array(
  123. 'post_type' => 'product',
  124. 'paged' => $paged,
  125. 's'=>$keywd,
  126. 'tax_query' => array(
  127. array(
  128. 'taxonomy' => 'product_cat',
  129. 'field' => 'slug',
  130. 'terms' => 'products'
  131. )
  132. )
  133. );
  134.  
  135. $gallery = new WP_Query($args);
  136. //print_r($gallery);
  137. ?>
  138. <?php wp_reset_postdata();?>
  139.  
  140. <?php
  141. if($gallery->have_posts()) :
  142. while($gallery->have_posts()): $gallery->the_post();?>
  143. <div class="prd-sec">
  144. <?php $ret=get_post_meta( get_the_ID(), 'wpcf-game-instructions', true );
  145. if($ret == '')
  146. {
  147. ?>
  148.  
  149. <a href="#" class="product-thump-img"><?php the_post_thumbnail('blog-small');?></a>
  150. <?php
  151. echo "<b>".the_title()."</b> : No Instruction PDF Found";
  152. }
  153. else
  154. {
  155. ?>
  156. <a href="<?php echo get_post_meta( get_the_ID(), 'wpcf-game-instructions', true ) ?>" class="product-thump-img"><?php the_post_thumbnail('blog-small');?></a>
  157. <a href="<?php echo get_post_meta( get_the_ID(), 'wpcf-game-instructions', true ) ?>"><?php the_title();?> Instructions</a>
  158.  
  159. <?php
  160. }
  161. ?>
  162. </div>
  163. <?php endwhile;
  164. else:
  165. ?>
  166. <p style="color:red">No Search Found</p>
  167. <?php
  168. endif;
  169. }
  170. ?>
  171. <?php
  172.  
  173. }
  174. ?>
  175. </div>
  176.  
  177. <div class="serviceright"><?php get_sidebar('servicesright'); ?>
  178. </div>
  179. </div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement