Alberto González Quintanilla Programador web

Alberto González

Desarrollador Web y Profesor de WordPress

Cómo solucionar el problema de las fechas en bbpress
albgonzalez13
0 comentarios

A continuación os dejo una función que soluciona el problema que esta teniendo bbPress (sistema de foro para WordPress) con las fechas.
Recuerda guardarla en tu bbpress-function.php de tu theme de bbpress.

 	'
    ', 'after' => '
', 'link_before' => '
  • ', 'link_after' => '
  • ', 'count_before' => ' (', 'count_after' => ')', 'count_sep' => ', ', 'separator' => ' ', 'forum_id' => '', 'show_topic_count' => true, 'show_reply_count' => true, 'freshness_before' => '', 'freshness_after' => '', 'show_freshness_link' => true ); $r = wp_parse_args( $args, $defaults ); extract( $r, EXTR_SKIP ); if ( !bbp_get_forum_subforum_count( $forum_id ) ) return; if ( $sub_forums = bbp_forum_get_subforums( $forum_id ) ) { $total_subs = count( $sub_forums ); foreach ( $sub_forums as $sub_forum ) { $i++; $count = array(); $show_sep = $total_subs > $i ? $separator : ''; $permalink = bbp_get_forum_permalink( $sub_forum->ID ); $title = bbp_get_forum_title( $sub_forum->ID ); if ( !empty( $show_topic_count ) && !bbp_is_forum_category( $sub_forum->ID ) ) $count['topic'] = bbp_get_forum_topic_count( $sub_forum->ID ); if ( !empty( $show_reply_count ) && !bbp_is_forum_category( $sub_forum->ID ) ) $count['reply'] = bbp_get_forum_reply_count( $sub_forum->ID ); if ( !empty( $count ) ) $counts = $count_before . implode( $count_sep, $count ) . $count_after; /** * A continuación está el código que he generado, y que solventa el problema. **/ // Buscamos cual es la última actividad $last_active = get_post_meta( $sub_forum->ID, '_bbp_last_active_time', true ); $link_url = bbp_get_forum_last_topic_permalink( $sub_forum->ID ); if ( empty( $last_active ) ) { $last_active = get_post_field( 'post_date', $sub_forum->ID ); $link_url = bbp_get_forum_last_topic_id( $sub_forum->ID ); } else { $last_active = bbp_get_topic_last_active_time( $sub_forum->ID ); $link_url = bbp_get_forum_last_topic_permalink( $sub_forum->ID ); } // Generamos la URL $anchor = '' . $last_active . ''; // Unimos todas las partes $freshness_link = $freshness_before . $anchor . $freshness_after; $output .= $link_before . '' . $title . $counts . $freshness_link . '' . $show_sep . $link_after; } echo $before . $output . $after; } } ?>