Advertisement
nonameolsson

WPUF Pro Query

Sep 1st, 2013
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.09 KB | None | 0 0
  1.         <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
  2.             <header class="entry-header">
  3.                 <h1 class="entry-title"><?php the_title(); ?></h1>
  4.             </header>
  5.  
  6.             <!-- The Loop -->
  7.             <?php
  8.                 while ( have_posts() ) : the_post();
  9.                     the_content();
  10.                 endwhile; // end of the loop.
  11.             ?>     
  12.            
  13.             <?php
  14.                 //Retrieves the current logged in user information
  15.                 $current_user = wp_get_current_user();
  16.                 if ( !($current_user instanceof WP_User) )
  17.                     return;
  18.             ?>
  19.  
  20.             <?php
  21.                 $args = array(  'post_type'         =>  'deviation',
  22.                                 'posts_per_page'    =>  '-1', // All in one page
  23.                                 'author'            =>  $current_user->ID,
  24.                                 'order'             =>  'DESC', // Start with first date of month
  25.                                 'orderby'           =>  'meta_value', // Sorting by date of month
  26.                                 'meta_key'          =>  'dev_date', // Which field to check - The date field
  27.                                 'post_status'       =>  'all',
  28.                 );
  29.                 $query = new WP_Query( $args );
  30.                 if( $query->have_posts() ) { ?>
  31.                     <table id="allDeviations">
  32.                         <thead>
  33.                             <tr>
  34.                                 <th>Anledning</th>
  35.                                 <th>Datum</th>
  36.                                 <th>Status</th>
  37.                                 <th>Åtgärd</th>
  38.                             </tr>
  39.                         </thead>
  40.                         <tbody><?php
  41.                             while ($query->have_posts()) : $query->the_post(); ?>
  42.                                 <tr>
  43.                                     <td><?php
  44.                                         $mykey_values = get_post_custom_values('dev_reason');
  45.                                         foreach ( $mykey_values as $key => $value ) {
  46.                                             echo "$value";
  47.                                         } ?>
  48.                                     </td>
  49.                                     <td><?php
  50.                                         $mykey_values = get_post_custom_values('dev_date');
  51.                                         foreach ( $mykey_values as $key => $value ) {
  52.                                             echo "$value";  
  53.                                         } ?>
  54.                                     </td>    
  55.  
  56.  
  57.  
  58.                                     <td>
  59.                                         <?php echo $post->post_status; ?>
  60.                                     </td>
  61.                                     <td><?php
  62.                                         if ( (wpuf_get_option( 'enable_post_edit', 'wpuf_dashboard' ) == 'yes') && (wpuf_get_option('enable_post_del', 'wpuf_dashboard', 'yes') == 'yes') && ( ($post->post_status != 'publish') )) {
  63.                                             $del_url = add_query_arg( array('action' => 'del', 'pid' => $post->ID) );
  64.                                             $edit_page = (int) wpuf_get_option( 'edit_page_id', 'wpuf_general' );
  65.                                             $edit_url = add_query_arg( array('pid' => $post->ID), get_permalink( $edit_page ) );                                               
  66.                                             ?>
  67.                                             <a href="<?php echo wp_nonce_url( $del_url, 'wpuf_del' ) ?>" onclick="return confirm('Are you sure to delete?');"><span style="color: red;"><?php _e( 'Delete', 'wpuf' ); ?></span></a>
  68.                                             <a href="<?php echo wp_nonce_url( $edit_url, 'wpuf_edit' ); ?>"><?php _e( 'Edit', 'wpuf' ); ?></a>
  69.                                             <?php
  70.                                    
  71.                                         } ?>
  72.                                     </td>              
  73.                                 </tr><?php
  74.                             endwhile;
  75.                         echo '</tbody>';
  76.                     echo '</table>';
  77.                 } else {
  78.                     echo '<p>Inga avvikelser är registrerade.</p>';
  79.                 }
  80.                 wp_reset_query();  // Restore global post data stomped by the_post().
  81.             ?>
  82.  
  83.         </article>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement