WPIntell

Source evidence

excluding post from certain category

Time Machine · support · 2011-06-18T04:03:00+00:00

mixedsentiment
highseverity
0.95relevance
7replies
Evidence linked to opportunitycommercial context

Proof Health

Open evidence

Commercial opportunities need traceable source links before they are treated as build-worthy.

4 / 27 rows with source links

14.8% of this page's analysis has direct source links.

0 build-decision rows missing links

0 rows here require auditable proof before promotion.

23 rows with no attached evidence

0 rows have source counts but still need direct links.

Conversation

support
pauro resolved
Hi, I have been a long time user of time-machine plugin, it works great until I found out that I have to exclude some post from some cats. I realize that by default this plugin does not have those function. I did a digging and found this (at line 233): $q = "SELECT ID, post_title, post_date, post_excerpt, comment_count FROM $wpdb->posts WHERE post_status='publish' AND post_type <> 'attachment' AND post_type <> 'revision' $tm_private $tm_pages AND $q_range $tm_current ORDER BY post_date LIMIT ".$options['posts']; I think this is the place to mess around to do what I want. But with my lacks of knowledge of sql’s, I need some help coding. Logically in human language it probably goes like this: get data FROM wpdb->post (like original code above) then cross the data with wpdb->tems NOT IN term ID ‘1,2,3’. Any suggestion appreciated pauro 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 | . 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? Work perfect. Thanks! 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

Comments

7 shown
Aleksandar Urošević 2011-06-18T07:39:00+00:00

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 | .

pauro 2011-06-18T10:41:00+00:00

Nicely done,perfect solution, thank you so much.

swf2002 2012-03-27T07:03:00+00:00

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

swf2002 2012-03-27T12:02:00+00:00

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?

Aleksandar Urošević 2012-03-27T13:04:00+00:00

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?

swf2002 2012-03-27T22:08:00+00:00

Work perfect. Thanks!

swf2002 2012-03-28T04:50:00+00:00

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