Info
- 10 posts
- 2 voices
- Started 5 years ago by chrishajer
- Latest reply from chrishajer
search.php enhancement request
-
- Posted 5 years ago #
I've modified search.php a bit to make the results a little more readable (to my eye) and I was wondering how to get the poster name, to display with the results for recent posts and relevant posts.
I would like to display something like:
<a href="<?php post_link(); ?>"><?php topic_title($bb_post->topic_id); ?></a> <small><?php _e('Posted') ?> <?php echo date(__('F j, Y, h:i A'), bb_get_p
ost_time()); ?></small> [BY MEMBER]the [BY MEMBER] part, to get the name of the member who made the post that is listed is the part I need help with. Thank you.
-
- Posted 5 years ago #
You should be able to do this:
get_user_name($bb_post->poster_id)Tell me if that doesn't work.
-
- Posted 5 years ago #
That does not work :)
Here is the code I am using:
<?php foreach ( $recent as $bb_post ) : ?>
<li><a href="<?php post_link(); ?>"><?php topic_title($bb_post->topic_id); ?></a><small> <?php _e('Posted') ?> <?php echo date(__('F j, Y, h:i A'), bb_get_post_time()); ?><?php _e(' by ')?><?php get_user_name($bb_post->poster_id) ?></small>seems like it should work. It doesn't error out, it's just blank after the " by "
Is there a list of functions, similar to the WP codex, where I could learn about them?
Thanks.
-
- Posted 5 years ago #
bb_get_user($bb_post->poster_id)also did not work (does not error, just shows no output.)also
$bb_post->poster_iddoes not return anything either. -
- Posted 5 years ago #
Try this
echo bb_get_user($bb_post->poster_id)->user_loginOr you can try to do it the way topics do it and just use this:
post_author_link();That will also return the name as a link to their webpage.
Worth a try I guess.
-
- Posted 5 years ago #
If neither of those work, you need to echo $bb_post->poster_id and see if you're getting anything. If not, you gotta figure out wtf $bb_post contains.
-
- Posted 5 years ago #
OK - will try. Thank you for your help.
-
- Posted 5 years ago #
<?php _e(' by ')?><?php echo bb_get_user($bb_post->poster_id)->user_login ?>Returns the user's name. Perfect. Thanks.
-
- Posted 5 years ago #
Update: the above was working, but on the command line,
php -lcomplained:parse error, unexpected T_OBJECT_OPERATOR in... that lineI got this to work:
<?php _e(' by ') ?><a href="<?php user_profile_link($bb_post->poster_id); ?>"><?php echo get_user_name($bb_post->poster_id); ?></a>That's what was suggested initially: I' m not sure what I did wrong the first time around, but this is what is working now, with no parse errors. Thanks.
-
- Posted 5 years ago #
I wonder if the problem with this line:
bb_get_user($bb_post->poster_id)->user_loginis related to this style syntax and could be fixed in a similar manner (if necessary):
http://bbpress.org/forums/topic/401?replies=42#post-2140 -
You must log in to post.