klmonnot
Forum Replies Created
-
Forum: Fixing WordPress
In reply to: show last 30 days of post PER category nameI got it fix. I had to write my own query and add a table to get the data that looped thought the post and term name.
‘
/* get id */
$query = “SELECT * FROM category WHERE display=1”;
$result = mysql_query($query) or die(‘Unable to get Category Id’);
while ($row = mysql_fetch_array($result)) {
$id = stripslashes($row[‘cat_id’]);
$cat_term_id = stripslashes($row[‘term_id’]);
$name = stripslashes($row[‘cat_name’]);}
/* set display back to 0 for prev id*/
$query1 = “update category set display = ‘0’ where cat_id = $id”;
$result1 = mysql_query($query1) or die(‘Unable to update Category Display 0’);/* get next id */
$query2 = “select min(cat_id) from category
join $wpdb->term_taxonomy on ($wpdb->term_taxonomy.term_id = category.term_id)
join $wpdb->term_relationships ON ($wpdb->term_relationships.term_taxonomy_id = $wpdb->term_taxonomy.term_taxonomy_id)
join $wpdb->posts on ($wpdb->posts.ID = $wpdb->term_relationships.object_id)
where cat_id > $id and disable=1 and $wpdb->posts.post_date >= ‘” . date(‘Y-m-d’, strtotime(‘-30 days’)).”‘
AND $wpdb->posts.post_type = ‘post’
AND $wpdb->posts.post_status = ‘publish’ “;
$result2 = mysql_query($query2) or die(‘Unable to get next Category Id1’);
$row2 = mysql_fetch_row($result2);
$idnext = ($row2[0]);
if (strlen($idnext) < 1)
{
$query3 = “select min(cat_id) from category
join $wpdb->term_taxonomy on ($wpdb->term_taxonomy.term_id = category.term_id)
join $wpdb->term_relationships ON ($wpdb->term_relationships.term_taxonomy_id = $wpdb->term_taxonomy.term_taxonomy_id)
join $wpdb->posts on ($wpdb->posts.ID = $wpdb->term_relationships.object_id)
where disable=1 and $wpdb->posts.post_date >= ‘” . date(‘Y-m-d’, strtotime(‘-30 days’)).”‘
AND $wpdb->posts.post_type = ‘post’
AND $wpdb->posts.post_status = ‘publish’ “;
$result3 = mysql_query($query3) or die(‘Unable to get next Category Id2’);
$row3 = mysql_fetch_row($result3);$idnext = $row3[0];
}/* set display to 1*/
$query4 =”update category set display = ‘1’ where cat_id = ‘$idnext'”;
$result4 = mysql_query($query4) or die(‘Unable to update Category Display 1’);
‘Forum: Fixing WordPress
In reply to: show last 30 days of post PER category nameok,, here’s what I have seen so far. then a dept_names post that has posted older then the 30 days it return the else statement of no data. I would like to have it rerun my qurey to get the next dept_name and it’s post.. How can I do that. I have modified my code a bit: $name is the dept_name and $area is the category_name plus the dept_name. so $area = category_name=News. I get news by running a query on a table I created.
‘function filter_where($where = ”) {
//posts in the last 30 days
$where .= ” AND post_date > ‘” . date(‘Y-m-d’, strtotime(‘-30 days’)) . “‘”;return $where;
}
add_filter(‘posts_where’, ‘filter_where’);$args=array(
‘category_name’ => $name,
‘post_type’ => ‘post’,
‘post_status’ => ‘publish’,
‘showposts’ => 2,
);$my_query=new WP_Query($args);
echo “<div class=colSytle>”;
if( $my_query->have_posts() ) {
echo “<h3 class=headSytle>$name:</h3>”;
while ($my_query->have_posts()) : $my_query->the_post();
echo “<h4><a href=\””;
the_permalink();
echo “\”>”;
the_title();
echo “</h4><small>”;
the_time(‘F jS, Y’);
echo “</small>
<p>”;
$content = get_the_content(”,FALSE,”);
$cont = word_limiter($content);
echo my_multi_col_v2($cont.”…”);
echo”</p>
“;
endwhile;
wp_reset_query();
}else{echo “No Data”;
}
wp_reset_query();
remove_filter(‘posts_where’, ‘filter_where’);
echo “</div><!–colSytle–>”;
echo “</div><!–leftCont–>”;
‘Forum: Fixing WordPress
In reply to: show last 30 days of post PER category nameLet me try and say this better.. I only want the data from the Cat names and cat names that have post 30 days or newer to show up. Right now I do get the cat names with blank data, which is right because the dates are old. I need to get rid of the cat name that are blank and just loop thur to get the data for the cat names with the right dates. I hope I’ve made my self clear.