Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Add Time to Recent Post Widgets Extended (RPWE) WordPress plugin output (uses Simple HTML DOM PHP [1.9.1 here] to aid in the HTML traversing & insertion])
// Add Simple HTML DOM for PHP-based HTML/DOM Traversal
include 'include/simple_html_dom.php';
// Add Time info to Recent Post Widgets Extended output (add after date)
function add_time_to_rpwe_markup($html,$args){
$html = str_get_html($html);
foreach($html->find('.rpwe-title a') as $title_link){
$permalink = $title_link->href;
$post_id = url_to_postid($permalink);
$time = get_the_date( 'g:i A', $post_id );
$title_tag = $title_link->parent();
$post_element = $title_tag->parent();
foreach($post_element->find('.rpwe-time') as $time_element){
$time_element_innerhtml = $time_element->innertext;
$time_element->innertext = $time_element_innerhtml.' '.$time;
$html_output = $html; // Convert back to string
return $html_output;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment