我在搜索中使用了这个额外的查询。php:
$search_string = esc_attr( trim( get_query_var(\'s\') ) );
$wp_user_query = new WP_User_Query( array(
\'meta_query\' => array(
\'relation\' => \'OR\',
array(
\'key\' => \'first_name\',
\'value\' => $search_string,
\'compare\' => \'LIKE\'
),
array(
\'key\' => \'last_name\',
\'value\' => $search_string,
\'compare\' => \'LIKE\'
)
)
) );
使用自定义循环:
<?php
// Get the results
$authors = $wp_user_query->get_results();
// Check for results
if ( ! empty( $authors ) ) { ?>
<?php foreach ( $authors as $author ) {
// get all the user\'s data
$author_info = get_userdata( $author->ID );
?>
<article class="post">
<header class="entry-header">
<h1 class="entry-title"><?php echo $author_info->display_name; ?></h1>
</header>
<div class="entry-content">
<p><?php echo wp_trim_words( get_the_author_meta(\'description\',$author_info->ID), 50, \'...\' ); ?></p>
<a href="/author/<?php echo $author_info->user_nicename; ?>" class="arrowafter">Lees verder</a>
</div>
</article>
<?php } ?>
<?php } ?>