Image – avatar in search results

Home Forums Product Support Forums Ajax Search Pro for WordPress Support Image – avatar in search results

This topic contains 4 replies, has 2 voices, and was last updated by sabbella sabbella 5 years ago.

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #22416
    sabbella
    sabbella
    Participant

    Hello Ernest,

    Excuseme for writing again for the same topic I opened before; I can’t find a solution for it.

    I’m still trying to display the wp_get_attachment_image from the users in my theme default search results page in order to display it next to their usernames as avatar.

    The code I have can display correctly $args and $avatar in the header of the page, AND $args in the users list search results, but not $avatar in the users list search results.

    I think it coul be because it can’t get correctly $user->ID in the user list search results, so I would like to ask you the way Ajax Search Pro plugin get users in the search results page in order to modify my code.

    This is what I have now:

    function my_user_avatar_filter( $avatar, $id_or_email, $args) {

    $id_or_email = get_userdata($id_or_email);

    $attachment_id = get_user_meta( $id_or_email->ID, ‘foto’, true );

    if (get_user_meta( $id_or_email->ID, ‘foto’, true )){

    //$avatar_url = wp_get_attachment_url( $attachment_id, $size );
    //$avatar = ““;

    $size= array(’80’,’80’);

    $avatar = wp_get_attachment_image($attachment_id, $size);

    echo $avatar;

    } else {

    $args=”“;

    echo $args;
    }
    }
    add_filter( ‘get_avatar’, ‘my_user_avatar_filter’, 10, 3 );

    Thank you,

    #22429
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    Hi,

    Well, this custom code looks okay to me, it is very hard to tell where the problem might be. It is very much possible, that the ‘get_avatar’ hook might not be executed whatsoever within the results page context. Maybe directly editing the theme file would be a better idea instead of using a custom hook, I am not sure.

    Best,
    Ernest Marcinko

    If you like my products, don't forget to rate them on codecanyon :)


    #22432
    sabbella
    sabbella
    Participant

    Thank you Ernes, I’ll try that way.

    #22448
    sabbella
    sabbella
    Participant

    Hi Ernest, would it be possible to display de images using the advanced title field {foto} in some way ? {foto} just displays the image ID

    Thank you,

    #22449
    sabbella
    sabbella
    Participant

    Hello Ernest, I found a way of doing it,

    Thank you 🙂

Viewing 5 posts - 1 through 5 (of 5 total)

The topic ‘Image – avatar in search results’ is closed to new replies.