No Results Found
The page you requested could not be found. Try refining your search, or use the navigation above to locate the post.
/** * Put products with pa_after-build-photos in this order: * Yes first, No second, Not set last. */ add_filter( 'posts_clauses', function( $clauses, $query ) { if ( is_admin() || ! $query instanceof WP_Query ) { return $clauses; } if ( ! $query->get( 'mhfp_after_build_photos_first' ) ) { return $clauses; } global $wpdb; $taxonomy = 'pa_after-build-photos'; $yes_term = get_term_by( 'slug', 'yes', $taxonomy ); $no_term = get_term_by( 'slug', 'no', $taxonomy ); $yes_ttid = ( $yes_term && ! is_wp_error( $yes_term ) && ! empty( $yes_term->term_taxonomy_id ) ) ? (int) $yes_term->term_taxonomy_id : 0; $no_ttid = ( $no_term && ! is_wp_error( $no_term ) && ! empty( $no_term->term_taxonomy_id ) ) ? (int) $no_term->term_taxonomy_id : 0; if ( ! $yes_ttid && ! $no_ttid ) { return $clauses; } $yes_alias = 'mhfp_abp_yes_rel'; $no_alias = 'mhfp_abp_no_rel'; if ( $yes_ttid && false === strpos( $clauses['join'], " AS {$yes_alias}" ) ) { $clauses['join'] .= $wpdb->prepare( " LEFT JOIN {$wpdb->term_relationships} AS {$yes_alias} ON {$wpdb->posts}.ID = {$yes_alias}.object_id AND {$yes_alias}.term_taxonomy_id = %d ", $yes_ttid ); } if ( $no_ttid && false === strpos( $clauses['join'], " AS {$no_alias}" ) ) { $clauses['join'] .= $wpdb->prepare( " LEFT JOIN {$wpdb->term_relationships} AS {$no_alias} ON {$wpdb->posts}.ID = {$no_alias}.object_id AND {$no_alias}.term_taxonomy_id = %d ", $no_ttid ); } $after_build_order = " CASE WHEN {$yes_alias}.object_id IS NOT NULL THEN 0 WHEN {$no_alias}.object_id IS NOT NULL THEN 1 ELSE 2 END ASC "; if ( ! empty( $clauses['orderby'] ) ) { $clauses['orderby'] = "{$after_build_order}, {$clauses['orderby']}"; } else { $clauses['orderby'] = "{$after_build_order}, {$wpdb->posts}.menu_order ASC, {$wpdb->posts}.post_title ASC"; } return $clauses; }, 999, 2 );
Find the perfect house plan. For less.