Hello Pauro. Here is dirty fix for this categoy excluding from Time Machine.
Find line 250 in time-machine.php and replace this code:
foreach ( $r as $post )
{
// prepare excerpt
if ( $tm_excerpt == TRUE ) {
$tm_post_excerpt = $post->post_excerpt;
if ( $tm_excerpt_cut == TRUE ) {
if ( $tm_excerpt_length && mb_strlen($tm_post_excerpt) > ($tm_excerpt_length+1) ) { $tm_post_excerpt = tm_substr_utf8($tm_post_excerpt, 0, $tm_excerpt_length)."…"; }
}
}
// print formated post line
if ( $options['display_commentnum'] == "1" ) { $pcount = ' (<span title="'.__("Number of comments", "tm").'">'.$post->comment_count.'</span>)'; } else { $pcount = ""; }
echo '<li>'.substr($post->post_date,0,4).': <a href="'.get_permalink($post->ID).'" title="'.__("Published at", "tm").' '.$post->post_date.'">'.$post->post_title.'</a>'.$pcount.' '.$tm_excerpt_before.$tm_post_excerpt.$tm_excerpt_after.'</li>';
}
with this code:
foreach ( $r as $post )
{
$pcats = get_the_category($post->ID);
$no_this = 0;
foreach ($pcats as $pcat) {
if ( preg_match("/(5|2)/", $pcat->cat_ID) ) { $no_this = 1; }
}
if ($no_this <> 1) {
// prepare excerpt
if ( $tm_excerpt == TRUE ) {
$tm_post_excerpt = $post->post_excerpt;
if ( $tm_excerpt_cut == TRUE ) {
if ( $tm_excerpt_length && mb_strlen($tm_post_excerpt) > ($tm_excerpt_length+1) ) { $tm_post_excerpt = tm_substr_utf8($tm_post_excerpt, 0, $tm_excerpt_length)."…"; }
}
}
// print formated post line
if ( $options['display_commentnum'] == "1" ) { $pcount = ' (<span title="'.__("Number of comments", "tm").'">'.$post->comment_count.'</span>)'; } else { $pcount = ""; }
echo '<li>'.substr($post->post_date,0,4).': <a href="'.get_permalink($post->ID).'" title="'.__("Published at", "tm").' '.$post->post_date.'">'.$post->post_title.'</a>'.$pcount.' '.$tm_excerpt_before.$tm_post_excerpt.$tm_excerpt_after.'</li>';
} //no_this
}
And also replace in line if ( preg_match("/(5|2)/", $pcat->cat_ID) ) { $no_this = 1; } numbers 5|2 with category ID’s you wish to exclude, separated with pipe sign |.
Thread Starter
pauro
(@pauro)
Nicely done,perfect solution, thank you so much.
Hello great plugin. I want to show just one Category and to exlcude: 5,2,28,57,10,8,20,2,4,29,3,56
How this must to look?
if ( preg_match(“/(5|2|28|57|10|8|20|2|4|29|3|56)/”, $pcat->cat_ID) ) { $no_this = 1; }
is not working
Thanks
I want to use that plugin for a “On this day is happen:”. This data will be take from category with ID=58. I want to exclude all other categories. When I write all my categires instead of 58 … it is no work, when I take from the list just one of the category it is work but I want to show only CAT=58… and none from others. Can you help?
Huh, w/o digging code again, instead of using if( preg_match… ) use exact match
if ( $pcat->cat_ID != 58 ) { $no_this = 1; }
Does this dirty hack works as U expected?
urkekg, just one simple question. What can be the reasson the changes of the plugin to show years ago events from can 58 to be change not in 00:00 my time, because in 1:30 AM they are stil from previos date. On the morning, about 7:00 AM they are with correct date. I assume is somthing with the time zone. My wordpress clock is correctly setup as our time in Bulgaria +3:00 GMT.
Thanks