如何编辑BBP_FOORMARY_FRENHINITY_LINK()格式

时间:2012-12-27 作者:Ed T.

我正在试图找到如何编辑的格式bbp_forum_freshness_link() bbpress插件中的函数。E、 g.当前它显示上次活动的天数,我想显示日期。因此,如果有人想分享一些想法或代码片段,那就太好了。

2 个回复
最合适的回答,由SO网友:fuxia 整理而成

我现在无法测试它,但它应该是这样工作的:

add_filter( \'bbp_get_forum_freshness_link\', \'wpse_77441_change_time_format\', 10, 2 );

function wpse_77441_change_time_format( $anchor, $forum_id )
{
    $last_active = get_post_meta( $forum_id, \'_bbp_last_active_time\', true );

    if ( empty( $last_active ) ) {
        $reply_id = bbp_get_forum_last_reply_id( $forum_id );

        if ( !empty( $reply_id ) ) {
            $last_active = get_post_field( \'post_date\', $reply_id );
        } else {
            $topic_id = bbp_get_forum_last_topic_id( $forum_id );

            if ( !empty( $topic_id ) ) {
                $last_active = bbp_get_topic_last_active_time( $topic_id );
            }
        }
    }

    $date       = bbp_convert_date( $last_active );
    $time_since = bbp_get_forum_last_active_time( $forum_id );

    return str_replace( "$time_since</a>", "$date</a>", $anchor );
}

SO网友:user39260
function wpse_77441_change_time_format( $anchor, $forum_id )
{
    $last_active = get_post_meta( $forum_id, \'_bbp_last_active_time\', true );

    if ( empty( $last_active ) ) {
        $reply_id = bbp_get_forum_last_reply_id( $forum_id );

        if ( !empty( $reply_id ) ) {
            $last_active = get_post_field( \'post_date\', $reply_id );
        } else {
            $topic_id = bbp_get_forum_last_topic_id( $forum_id );

            if ( !empty( $topic_id ) ) {
                $last_active = bbp_get_topic_last_active_time( $topic_id );
            }
        }
    }

      $date   = get_post_time( get_option( \'date_format\' ), $gmt, $reply_id, true );
      $time   = get_post_time( get_option( \'time_format\' ), $gmt, $reply_id, true );
      $dt = sprintf( _x( \'%1$s at %2$s\', \'date at time\', \'bbpress\' ), $date, $time );    

    $time_since = bbp_get_forum_last_active_time( $forum_id );


    return str_replace( "$time_since</a>", "$dt</a>", $anchor );
}
add_filter( \'bbp_get_forum_freshness_link\', \'wpse_77441_change_time_format\', 10, 2 );
结束

相关推荐

在bbPress中创建嵌套论坛循环

我正在为bbPress创建一个定制的论坛首页,以不同于bbPress默认设置的方式列出论坛。从本质上讲,我试图用第二个嵌套的bbPress循环来取代bbp\\u list\\u forums()的使用,这样我就可以更好地控制子论坛的显示方式。我知道我可以使用bbp\\u list\\u forums()的“before”和“after”参数,但这并不能给我提供所需的控制。我发现唯一接近的问题是this one 这实际上并没有提供一个明确的答案。到目前为止,我的代码是这样的;<?php while (