qa
Signed-off-by: Jeff <jeff@gotenzing.com>
Showing
2 changed files
with
23 additions
and
57 deletions
| ... | @@ -34,16 +34,20 @@ function pull_posts_for_post_list( $data ) { | ... | @@ -34,16 +34,20 @@ function pull_posts_for_post_list( $data ) { |
| 34 | $posts = get_posts( array( | 34 | $posts = get_posts( array( |
| 35 | 'category' => $categories, | 35 | 'category' => $categories, |
| 36 | 'numberposts' => $numberposts, | 36 | 'numberposts' => $numberposts, |
| 37 | 'order' => 'DESC', | 37 | 'suppress_filters' => false, |
| 38 | 'suppress_filters' => false | 38 | |
| 39 | 'orderby' => 'menu_order', | ||
| 40 | 'order' => 'DESC' | ||
| 41 | |||
| 39 | ) ); | 42 | ) ); |
| 40 | } else { | 43 | } else { |
| 41 | $posts = get_posts( array( | 44 | $posts = get_posts( array( |
| 42 | 'numberposts' => $numberposts, | 45 | 'numberposts' => $numberposts, |
| 43 | 'order' => 'DESC', | ||
| 44 | 'suppress_filters' => false, | 46 | 'suppress_filters' => false, |
| 45 | 'category_not_in'=>$exclude, | 47 | 'category_not_in'=>$exclude, |
| 46 | 'exclude' => $exclude_posts, | 48 | 'exclude' => $exclude_posts, |
| 49 | 'orderby' => 'menu_order', | ||
| 50 | 'order' => 'DESC' | ||
| 47 | ) ); | 51 | ) ); |
| 48 | } | 52 | } |
| 49 | 53 | ... | ... |
| ... | @@ -10,66 +10,29 @@ function add_attachment_mime_type( $attachment_id ){ | ... | @@ -10,66 +10,29 @@ function add_attachment_mime_type( $attachment_id ){ |
| 10 | 10 | ||
| 11 | } | 11 | } |
| 12 | 12 | ||
| 13 | function exclude_in_search_results( $query ) { | ||
| 14 | |||
| 15 | if ( $query->is_main_query() && $query->is_search() && ! is_admin() ) { | ||
| 16 | |||
| 17 | $query->set( 'post_type', array( 'attachment', 'documents') ); | ||
| 18 | |||
| 19 | $query->set( 'meta_query', array ( | ||
| 20 | 'relation' => 'OR', | ||
| 21 | array ( | ||
| 22 | 'relation' => 'AND', | ||
| 23 | array( | ||
| 24 | 'key' => 'exclude_from_search', | ||
| 25 | 'value' => 1, | ||
| 26 | 'compare' => '!=', | ||
| 27 | ), | ||
| 28 | ), | ||
| 29 | ) ); | ||
| 30 | |||
| 31 | |||
| 32 | } | ||
| 33 | } | ||
| 34 | add_action( 'pre_get_posts', 'exclude_in_search_results' ); | ||
| 35 | |||
| 36 | // if(get_locale() == 'fr_FR') { | ||
| 37 | // $query->set( 'meta_query', array ( | ||
| 38 | // 'relation' => 'OR', | ||
| 39 | // array ( | ||
| 40 | // 'relation' => 'AND', | ||
| 41 | // array( | ||
| 42 | // 'key' => 'wpml', | ||
| 43 | // 'value' => 'FR', | ||
| 44 | // 'compare' => '==', | ||
| 45 | // ), | ||
| 46 | // ), | ||
| 47 | // ) ); | ||
| 48 | |||
| 49 | // }else{ | ||
| 50 | // $query->set( 'meta_query', array ( | ||
| 51 | // 'relation' => 'OR', | ||
| 52 | // array ( | ||
| 53 | // 'relation' => 'AND', | ||
| 54 | // array( | ||
| 55 | // 'key' => 'wpml', | ||
| 56 | // 'value' => 'EN', | ||
| 57 | // 'compare' => '==', | ||
| 58 | // ), | ||
| 59 | // ), | ||
| 60 | // ) ); | ||
| 61 | // } | ||
| 62 | |||
| 63 | |||
| 64 | // apply tags to attachments | ||
| 65 | function wptp_add_tags_to_attachments() { | 13 | function wptp_add_tags_to_attachments() { |
| 66 | register_taxonomy_for_object_type( 'post_tag', 'attachment' ); | 14 | register_taxonomy_for_object_type( 'post_tag', 'attachment' ); |
| 67 | } | 15 | } |
| 68 | add_action( 'init' , 'wptp_add_tags_to_attachments' ); | 16 | add_action( 'init' , 'wptp_add_tags_to_attachments' ); |
| 69 | 17 | ||
| 70 | 18 | ||
| 19 | function filter_query_args( $query_args, $sfid ) { | ||
| 20 | $query_args['posts_per_page'] = -1; | ||
| 21 | $query_args['orderby'] = 'relevance'; | ||
| 22 | $query_args['order'] = 'ASC'; | ||
| 23 | |||
| 24 | error_log(print_r($query_args, true)); | ||
| 25 | return $query_args; | ||
| 71 | 26 | ||
| 27 | } | ||
| 28 | add_filter( 'sf_edit_query_args', 'filter_query_args', 99, 2 ); | ||
| 72 | 29 | ||
| 30 | function relevant_search_result( $q ) { | ||
| 31 | if ( is_search() && is_main_query() ) | ||
| 32 | $q->set( 'orderby', 'relevance'); | ||
| 33 | $q->set( 'order', 'ASC'); | ||
| 34 | } | ||
| 35 | add_action( 'pre_get_posts', 'relevant_search_result' ); | ||
| 73 | 36 | ||
| 74 | add_action('init','set_exclude_from_search'); | 37 | add_action('init','set_exclude_from_search'); |
| 75 | function set_exclude_from_search() | 38 | function set_exclude_from_search() |
| ... | @@ -139,4 +102,3 @@ function update_tax_counts() | ... | @@ -139,4 +102,3 @@ function update_tax_counts() |
| 139 | 102 | ||
| 140 | } | 103 | } |
| 141 | } | 104 | } |
| 142 | ... | ... |
-
Please register or sign in to post a comment