Home › Forums › Product Support Forums › Ajax Search Pro for WordPress Support › I can't get images to show for buddypress search results page
- This topic has 10 replies, 2 voices, and was last updated 6 years, 11 months ago by
Ernest Marcinko.
-
AuthorPosts
-
June 19, 2019 at 2:49 pm #23190
dando
ParticipantHi, I’ve got this problem on my site where when you search for buddypress users, on the results page there are no avatars, just names, in one solid column. I can solve the layout problem with elementor, but try as I can I can’t get the avatars to show up. images show up for any other post type
June 19, 2019 at 2:58 pm #23191dando
Participant
June 20, 2019 at 7:39 am #23197Ernest Marcinko
KeymasterHi,
Thank you for all the details. Unfortunately the plugin cannot affect the results page layout, it is fully controlled by the theme you are using. Usually themes support only post types with images, so profile images may not show there. It might be possible to get the images via a modification though. There is a theme function api available, but you will have to ask the theme author as well on how exactly modify the images within the theme files via a child theme.
In your case, you are looking to implement something like this, to pass the search images to the results page:
<?php $asp_img = get_asp_result_field('image'); if ( !empty($asp_img) ) { echo "<img src='$asp_img'>"; } ?>June 20, 2019 at 2:20 pm #23200dando
ParticipantIs this for groups only? I’m using Jupiter X, and I’ve added your code to the search.php fragment like this;
function jupiterx_post_image() { $asp_img = get_asp_result_field('image'); if ( !empty($asp_img) ) { echo "<img src='$asp_img' />"; }after this, if I search for a term that affects both groups and users, the search reveals the groups images, but not the users.
You can see the result here;
June 20, 2019 at 3:05 pm #23204Ernest Marcinko
KeymasterNo, it should work with anytthing there. Mabye something is overriding those images, I am not sure.
Try maybe a bit more advanced modification:
$asp_type = get_asp_result_field('content_type'); $asp_img = get_asp_result_field('image'); $asp_id = get_asp_result_field('id'); if ( !empty($asp_img) ) { echo "<img src='$asp_img' />"; } else if ( $asp_type == 'user' ) { if ( function_exists('bp_core_fetch_avatar') ) { $im = bp_core_fetch_avatar(array('item_id' => $asp_id, 'html' => false)); } else { $im = $this->get_avatar_url($asp_id); } if ( !empty($im) ) { echo "<img src='$im' />"; } }June 20, 2019 at 3:09 pm #23205dando
ParticipantThat did the trick 🙂 thank you so much Ernest, you’re a life saver
June 20, 2019 at 3:10 pm #23206Ernest Marcinko
KeymasterYou cannot access this content.
June 20, 2019 at 3:29 pm #23207dando
Participantjust one last thing – if I click on a user’s name, the link takes me to /author/admin/ instead of members/admin. is this a theme thing as well?
-
This reply was modified 6 years, 11 months ago by
dando.
June 20, 2019 at 3:40 pm #23209dando
Participantdon’t stress, I found the solution –
I’m putting it here in case anyone else has this problem, go to your functions.php and add this;
add_action(‘init’, ‘cng_author_base’);
function cng_author_base() {
global $wp_rewrite;
$author_slug = ‘members’; // change slug name
$wp_rewrite->author_base = $author_slug;
}This will modify the slug for authors
June 20, 2019 at 3:50 pm #23210dando
Participantcan the_asp_result_field return a link to the profile?
June 21, 2019 at 8:54 am #23216Ernest Marcinko
KeymasterHi,
Not sure about that, it may not work, but if so, then it should return the same link as set here.
<a href="<?php echo get_asp_result_field('link'); ?>">My link</a> -
This reply was modified 6 years, 11 months ago by
-
AuthorPosts
- You must be logged in to reply to this topic.