0

I'm looking to output a link to the users profile link so the searched username is clickable, please see the following code that's sitting in search.php:

<?php 
                            $s_query = get_search_query();
                            $args = array(
                                'search' => '*' . esc_attr( $s_query ) . '*',
                                array(
                                    'key'     => 'first_name',
                                    'value'   => $search_term,
                                    'compare' => 'LIKE'
                                ),
                                array(
                                    'key'     => 'last_name',
                                    'value'   => $search_term,
                                    'compare' => 'LIKE'
                                )
                            );
                            $user_query = new WP_User_Query( $args );
                            if ( ! empty( $user_query->get_results() ) ) {
                                foreach ( $user_query->get_results() as $user ) {
                                    echo '<p>' . $user->display_name . '</p>';
                                    echo '<p>Test</p>';
                                }
                            } else {
                                echo 'There are no users matching your search.';
                            }
                        ?>

Please can you help. I've tried using '$user->user_link' and '$user->url'.

Any ideas?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.