Advertisement
Daniel_Dropik

page-sr

May 20th, 2014
287
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.70 KB | None | 0 0
  1. <?php
  2. /**
  3.  * The template for displaying all pages.
  4.  *
  5.  * This is the template that displays all pages by default.
  6.  * Please note that this is the WordPress construct of pages
  7.  * and that other 'pages' on your WordPress site will use a
  8.  * different template.
  9.  * @package WordPress
  10.  * @subpackage CALSv1
  11.  * @since CALS 1.0
  12.  */
  13.  
  14. get_header();
  15. //maps the raw $_GET data to array
  16. $gets =array("year"=> $_GET["yr"],"subject"=> $_GET["subject"], "author"=>$_GET["auth"], "keyword"=> $_GET["keyword"]);
  17.  
  18. //creates an array, for later use.
  19. $arr=array();
  20.  
  21. //accepts $gets array filters out unset values, updates $arr
  22. foreach ($gets as $key=>$val){
  23.     if(isset($val)){
  24.         $arr[$key]=$val;
  25.     }
  26. }
  27.  
  28.     switch($arr){
  29.         case (isset($arr["year"]) && isset($arr["subject"])):
  30.                 //print_r("year and author");
  31.                 $year=intval($arr["year"]);
  32.                 $subj=$arr["subject"];
  33.  
  34.                     $args = array(
  35.             'numberposts' => -1,
  36.             'post_type' => 'wcmc',
  37.             'meta_query' => array(
  38.                                     'relation' => 'AND',
  39.                                             array(
  40.                                                 'key' => 'date', //gets ACF value assoc with 'date'
  41.                                                 'compare' => '=',
  42.                                                 'value' => $year // gets value from $arr, which gets value from dropdown
  43.                                                 ),
  44.                                             array(
  45.                                                 'key' => 'subject',
  46.                                                 'value' => $subj,
  47.                                                 'compare' => '='
  48.                                             )
  49.                                 )
  50.                 );
  51.         break;
  52.  
  53.         case (isset($arr["year"]) && isset($arr["author"])):
  54.         $year=intval($arr["year"]);
  55.         $author=$arr["author"];
  56.  
  57.                     $args = array(
  58.             'numberposts' => -1,
  59.             'post_type' => 'wcmc',
  60.             'meta_query' => array(
  61.                                     'relation' => 'AND',
  62.                                             array(
  63.                                                 'key' => 'date', //gets ACF value assoc with 'date'
  64.                                                 'compare' => '=',
  65.                                                 'value' => $year //val of dropdown
  66.                                             ),
  67.                                             array(
  68.                                                 'key' => 'author_name1', //gets ACF value assoc with 'author_name1'
  69.                                                 'value' => $author, // gets value from $arr, which gets value from dropdown
  70.                                                 'compare' => '='
  71.                                             )
  72.                                 )
  73.                 );
  74.         //print_r("year and author");
  75.         break;
  76.  
  77.         case (isset($arr["keyword"])):
  78.         $kywd=strtolower($arr["keyword"]);
  79.         $getTerms = get_terms('wcmc_keywords','hide_empty=0');
  80.         //$name_getTerms = $getTerms->name;
  81.         //print_r("all years and keyword");
  82.                         /*$args = array(
  83.                     'numberposts' => -1,
  84.                     'post_type' => 'wcmc',
  85.                     'meta_key' => 'kewywords',
  86.                     'meta_value' => $kywd
  87.                 ); */
  88.        
  89.                 $args=array(
  90.                     'post_type'=>'wcmc',
  91.                     'tax_query'=>array(
  92.                         array('taxonomy' => 'wcmc_keywords',
  93.                         'field' => 'slug',
  94.                         'terms' => $kywd)
  95.                         )
  96.                     );
  97.         break;
  98.  
  99.         default:
  100.         print_r("there has been an error");
  101.         break;
  102.  
  103.     }
  104. ?>
  105.  
  106.  
  107. <div class="mobileScroll">
  108. <a href="#" class="mobileNavTriggerLarge" style="display: none;"></a>
  109.  
  110.     <div id="main">
  111.  
  112.         <div id="primary">
  113.             <div id="content" role="main">
  114.                 <?php
  115.  
  116.                 // args
  117.                 /*$args = array(
  118.                     'numberposts' => -1,
  119.                     'post_type' => 'wcmc',
  120.                     'orderby' => 'meta_value_num',
  121.                     'order' => 'ASC'
  122.                 ); */
  123.                  
  124.                 // get results
  125.                 $the_query = new WP_Query( $args );
  126.                  
  127.                 // The Loop
  128.                 ?>
  129.                 <?php if( $the_query->have_posts() ): ?>
  130.                     <ul>
  131.                     <?php while ( $the_query->have_posts() ) : $the_query->the_post(); ?>
  132.                         <li>
  133.                             <a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
  134.                         </li>
  135.                     <?php endwhile; ?>
  136.                     </ul>
  137.                 <?php endif; ?>
  138.                  
  139.                 <?php wp_reset_query();  // Restore global post data stomped by the_post(). ?>
  140.  
  141.             </div><!-- #content -->
  142.         <?php get_sidebar(); ?>
  143.             <div class="clear"></div>
  144.  
  145.         </div><!-- #primary -->
  146.  
  147.     </div>
  148.  
  149.  
  150.    
  151. <?php echo $GLOBALS['wp_query']->request; ?>
  152. <?php get_footer(); ?>
  153.  
  154. </div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement