Answer the question
In order to leave comments, you need to log in
Why is wordpress not showing all search results (when querying MySQL they are), encoding?
Did a custom taxonomy search. I have this code:
<?php $search_term = explode( ' ', get_search_query( false ) );
global $wpdb;
$select = "
SELECT DISTINCT t.*, tt.*
FROM wp_terms AS t
LEFT JOIN wp_term_taxonomy AS tt
ON t.term_id = tt.term_id
LEFT JOIN wp_termmeta AS tm
ON t.term_id = tm.term_id
WHERE tt.taxonomy IN ('customtaxonomyname')";
$first = true;
foreach ( $search_term as $s ){
if ( $first ){
$select .= " AND (t.name LIKE '%s')";
$string_replace[] = '%'.$wpdb->esc_like( $s ).'%';
$first = false;
/*}else{
$select .= " OR (t.name LIKE '%s') OR (tm.meta_value LIKE '%s')";
$string_replace[] = '%'. $wpdb->esc_like( $s ).'%';*/
}
}
$select .= " ORDER BY t.name ASC";
$terms = $wpdb->get_results( $wpdb->prepare( $select, $string_replace ) );
if ( count($terms) > 0 ){
foreach ( $terms as $term ) {
if ($term->taxonomy == 'customtaxonomyname') {
//var_dump($search_term);
echo '<article id="post-" class="attachment type-attachment status-inherit hentry">';
echo '<header class="entry-header"><h2 class="entry-title"><a href="'.esc_url( get_term_link( $term ) ).'" title="'.esc_attr( $term->name ).'" rel="bookmark">' . esc_html( $term->name ) . '</a></h2><div class="entry-meta"></div></header>';
echo '<div class="entry-summary"></div><footer class="entry-footer"></footer></article>';
}
}
} ?>
/** Database Charset to use in creating database tables. */
define( 'DB_CHARSET', 'utf8mb4' );
/** The Database Collate type. Don't change this if in doubt. */
define( 'DB_COLLATE', 'utf8mb4_unicode_520_ci' ); - /* тут пробовал и пустое значение - все равно показывает не все результаты поиска*/
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question