View difference between Paste ID: rPYwF1TE and 1jhNf9fe
SHOW: | | - or go back to the newest paste.
1
// Script for getting posts
2
function ajax_filter_get_posts( $taxonomy ) {
3
  // Verify nonce
4
  if( !isset( $_POST['afp_nonce'] ) || !wp_verify_nonce( $_POST['afp_nonce'], 'afp_nonce' ) )
5
    die('Permission denied');
6
  $taxonomy = $_POST['taxonomy'];
7
  // WP Query
8
  $args = array( 
9
  //'tag' => $taxonomy,
10
  'post_type' => 'work', 
11
  'posts_per_page' => 1 
12
  /*'tax_query' => array( 
13
    array(
14
        'taxonomy' => 'filters',
15
        'terms' => array('100','99','154'),      
16
        'field' => 'id',
17
        'operator' => 'NOT IN' 
18
      )
19
  )*/
20
);
21
  // If taxonomy is not set, remove key from array and get all posts
22
  /*if( !$taxonomy ) {
23
    unset( $args['tag'] );
24
  }*/
25
  $query = new WP_Query( $args );
26
  if ( $query->have_posts() ) : while ( $query->have_posts() ) : $query->the_post(); ?>
27
  <!--<a href=""></a>-->
28
  <a href="http://www.youtube.com/watch?v=" class="prettyPhoto" title="">
29
    <img src="http://img.youtube.com/vi//2.jpg" class="prettyPhoto" title="">
30
  </a>
31
  <a href="http://vimeo.com/" class="prettyPhoto" title="">
32
  </a>
33
  <a href="#embedd-video" class="prettyPhoto" title="">
34
  </a>
35
  <a href="" class="prettyPhoto" title="">
36
  </a>
37
  <a href="" title="" class="pic">
38
  </a>
39
  <a href="" title="" class="video">
40
    <img src="http://img.youtube.com/vi//0.jpg" class="prettyPhoto" title="" width="215px">
41
  </a>
42
  <a href="" title="" class="pic">
43
    <img src="http://img.youtube.com/vi//0.jpg" class="prettyPhoto" title="" width="215px">
44
  </a>
45
  <a href=""></a>
46
  No posts found
47
  <?php 
48
  endif;
49
  die();
50
}
51
52
add_action('wp_ajax_filter_posts', 'ajax_filter_get_posts');
53
add_action('wp_ajax_nopriv_filter_posts', 'ajax_filter_get_posts');