0

I'm querying a custom field of users based on a city they are in. I am able to display their profile photo and display name, however I can't seem to get the link to their actual author url to work.

It just keeps linking to the same page it's currently on. Any help would be greatly appreciated.

<?php
        $london_args = array(   
            'meta_value'   => 'London',
        );

        // The Query
        $london_user_query = new WP_User_Query( $london_args );

        // User Loop
        if ( ! empty( $london_user_query->results ) ) {
            foreach ( $london_user_query->results as $user ) {

        ?>


            <li>    
                <?php if($user->user_cover_pic == '') { ?>
                Photo coming soon
                <?php } else { ?>
                <a href="<?php $user->url; ?>">
                    <img src="<?php echo $user->user_cover_pic; ?>" alt="<?php echo $user->display_name; ?>">
                </a>
                <?php }; ?><br>

                <a href="<?php $user->url; ?>"><?php echo $user->display_name; ?></a>
            </li>


        <?php
            }
        } else {

            echo 'No Lawyers found in London.';

        } ?>
1

2 Answers 2

2

I am not sure too much about the code but i think you forgot to echo $user->url

So just replace all $user->url with echo $user->url

1
  • Oh, good find on the echo. How silly of me to forget to try that. Unfortunately it is still linking to the same page. Commented Jan 12, 2016 at 0:01
-1

Solved it!

echo get_author_posts_url( $user->ID );

Thank you for replying, terminator. :) You at least got me in the right direction.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.