Sort search results
-
Hello, I have the results of a survey according to the image but would like to remain orderly.
Image for example: https://imgur.com/gallery/xAsFkNd/newfunction load_search_results() { $query = $_POST['query']; $args = array( 'post_type' => 'manual', 'post_status' => 'publish', 's' => $query, ); $search = new WP_Query( $args ); ob_start(); ?> <div class="search-content"> <h2>Resultados da pesquisa</h2> <?php if ( $search->have_posts() ) : ?> <?php while ( $search->have_posts() ) : $search->the_post(); $term = wp_get_post_terms( get_the_ID(), 'categoria' ); $term = $term[0]; $ancestors = array_reverse(get_ancestors( $term->term_id, 'categoria' )); foreach ( $ancestors as $ancestor ) { $ancestor = get_term_by( 'id', $ancestor, 'categoria' ); if ( ! is_null( $ancestor ) ) { echo '<strong>'.$ancestor->name.'</strong>'; echo ' -> '; } } echo '<strong>'.$term->name.'</strong>'; echo ' -> ';?> <span id="<?php echo get_the_ID();?>" class="search-title search-loader"> <?php the_title();?> </span> <?php echo '<br><br>'; endwhile; else : ?> <h2>Nada encontrado.</h2> <?php endif; ?> </div> <?php $content = ob_get_clean(); echo $content; die(); }
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Sort search results’ is closed to new replies.