How do I add timestamp to posts within a topic?
-
How do I add timestamp to posts within a topic? Thanks.
-
not quite sure what you are after, can you explain further ?
Please see this link. Thanks.
basically you’d need to cut some code to display the date/time, put it in a function that echo’s it, and then hook it to the following action
add_action (‘bbp_theme_before_reply_content’, ‘your_function’) ;
see
sorry am up to my armpits in other code, or I’d cut it for you !
Thanks for responding. I made the below code and unfortunately didn’t work. When you have time in a week or 2, would love to know what went wrong. Thanks.
function post_time ( $output) { $output = preg_replace( '/, .*[^ago]/', ' ', $output ); echo $output; } add_action ('bbp_theme_before_reply_content', 'post_time') ;
Have made a note to come back to this !
You can use bbp_reply_post_date for it – it will give you “August 4, 2012 at 2:37 pm”. I mean, it would give you that for posts on Aug 4, 2012 at 2.37pm and similar things for other dates.
But you want to style it a bit, so something like:
function mjj_post_reply_date(){ printf('<div class="mjj-post-date">'); bbp_reply_post_date(); printf('</div>'); } add_action ('bbp_theme_before_reply_content', 'mjj_post_reply_date') ;
Thanks. It works. Is there a way to only show the date and not the hour/minute? Maybe using code similar to the below could help?
function short_freshness_time( $output) { $output = preg_replace( '/, .*[^ago]/', ' ', $output ); return $output; }
Yep – use get_post_time() – https://codex.wordpress.org/Template_Tags/get_post_time
function mjj_post_reply_date(){ printf('<div class="mjj-post-date">'); $reply_id = bbp_get_reply_id( $reply_id ); printf( get_post_time( get_option( 'date_format' ), false, $reply_id, true ) ); printf('</div>'); } add_action ('bbp_theme_before_reply_content', 'mjj_post_reply_date') ;
It worked. Thanks.
glad you’re fixed !
- You must be logged in to reply to this topic.