Advertisement
Guest User

WP Query pages

a guest
Dec 2nd, 2010
324
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.90 KB | None | 0 0
  1. <?php
  2. /*
  3. Template Name: page-progetti-architecture
  4. */
  5. ?>
  6.  
  7. <?php $ordine= $_GET['ordine'];?>
  8.  
  9. <?php get_header(); ?>
  10.  
  11. <div class="grid_13" id="sezione">
  12.            
  13.     <?php
  14.         $querystr =
  15.         "SELECT wposts.*
  16.             FROM $wpdb->posts wposts, $wpdb->postmeta wpostmeta
  17.             WHERE wposts.ID = wpostmeta.post_id
  18.             AND wpostmeta.meta_key = 'Categoria'
  19.             AND wpostmeta.meta_value = 'Architecture'
  20.             AND wposts.post_type = 'page'
  21.             ORDER BY wpostmeta.meta_value DESC";
  22.         $pageposts = $wpdb->get_results($querystr, OBJECT);
  23.     ?>
  24.            
  25.     <?php
  26.         $sort= $_GET['ordine'];
  27.                
  28.         if($sort == "data"){
  29.             $querystr =
  30.             "SELECT wposts.*
  31.                 FROM $wpdb->posts wposts, $wpdb->postmeta wpostmeta
  32.                 WHERE wposts.ID = wpostmeta.post_id
  33.                 AND wpostmeta.meta_key = 'Categoria'
  34.                 AND wpostmeta.meta_value = 'Architecture'
  35.                 AND wposts.post_type = 'page'
  36.                 ORDER BY wpostmeta.meta_value DESC";
  37.             $pageposts = $wpdb->get_results($querystr, OBJECT);
  38.         }
  39.            
  40.         if($sort == "alfabeto"){
  41.             $querystr =
  42.             "SELECT wposts.*
  43.                 FROM $wpdb->posts wposts, $wpdb->postmeta wpostmeta
  44.                 WHERE wposts.ID = wpostmeta.post_id
  45.                 AND wpostmeta.meta_key = 'Categoria'
  46.                 AND wpostmeta.meta_value = 'Architecture'
  47.                 AND wposts.post_type = 'page'
  48.                 ORDER BY wpostmeta.meta_value DESC";
  49.             $pageposts = $wpdb->get_results($querystr, OBJECT);
  50.         }
  51.     ?>
  52.    
  53.     <div id="bread-and-ord">
  54.         <?php breadcrumb_trail( array( 'show_home' => false, 'before' => '', 'separator' => '&raquo;',) ); ?>
  55.         <br />
  56.         Ordina per:
  57.         <a href="?ordine=data">Data</a> - <a href="?ordine=alfabeto">Alfabeto</a>
  58.         <br />
  59.     </div>
  60.            
  61.     <?php if ($pageposts): ?>
  62.     <?php global $post; ?>
  63.     <?php foreach ($pageposts as $post): ?>
  64.     <?php setup_postdata($post);
  65.         // check for thumbnail
  66.         $thumb = get_post_meta($post->ID, 'Thumbnail', $single = true);
  67.         // check for thumbnail class
  68.         $thumb_class = get_post_meta($post->ID, 'Thumbnail Class', $single = true);
  69.         // check for thumbnail alt text
  70.         $thumb_alt = get_post_meta($post->ID, 'Thumbnail Alt', $single = true);
  71.     ?>
  72.  
  73.     <div class="post sezione-box" id="post-<?php the_ID(); ?>">
  74.         <?php // if there's a thumbnail
  75.             if($thumb !== '') {
  76.         ?>
  77.         <a href="<?php the_permalink() ?>">
  78.             <img
  79.                 src="<?php echo $thumb; ?>"
  80.                 class="<?php if($thumb_class !== '') { echo $thumb_class; } else { echo "left"; } ?>"
  81.                 alt="<?php if($thumb_alt !== '') { echo $thumb_alt; } else { echo the_title(); } ?>"
  82.             />
  83.             <p><?php the_title(); ?></p>
  84.         </a>
  85.         <?php
  86.             } // end if statement
  87.             // if there's not a thumbnail
  88.             else { echo ''; }
  89.         ?>
  90.     </div>
  91.  
  92.     <?php endforeach; ?>
  93.              
  94.     <?php else : ?>
  95.            
  96.     <h2 class="center">
  97.         Not Found
  98.     </h2>
  99.            
  100.     <p class="center">
  101.         Sorry, but you are looking for something that isn't here.
  102.     </p>
  103.            
  104.     <?php endif; ?>
  105.  
  106. </div>
  107.  
  108. <?php get_sidebar(); ?>
  109.  
  110. <?php get_footer(); ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement