fcarthy
Forum Replies Created
-
Forum: Fixing WordPress
In reply to: Will this code limit the posts displayed to the last 14 days?bump
Forum: Plugins
In reply to: Style Post Links Differently Based On Time Stamp?bump
Forum: Fixing WordPress
In reply to: Will this code limit the posts displayed to the last 14 days?I know I’m just milking it, but I also need to run this function twice on the same page. My ultimate goal is to have 2 separate counts of all new posts from 2 separate categories.
What do I need to change to do that?
Forum: Fixing WordPress
In reply to: need help counting number of new postst31os_ thank you so much for the in-depth response. I also got a response from MichaelH the moderator, this is what he suggested and it works:
<?php function filter_where($where = '') { //posts in the last 30 days $where .= " AND post_date > '" . date('Y-m-d', strtotime('-90 days')) . "'"; return $where; } add_filter('posts_where', 'filter_where'); $args=array( 'post_type' => 'post', 'post_status' => 'publish', 'showposts' => -1, 'caller_get_posts'=> 1 ); $my_query=new WP_Query($args); remove_filter('posts_where', 'filter_where'); if( $my_query->have_posts() ) { echo '<h2>Number of posts in last 90 days is '.count($my_query->posts) . '</h2>'; while ($my_query->have_posts()) : $my_query->the_post(); ?> <p><small><?php the_time('m.d.y') ?></small> <a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></p> <?php endwhile; } //if ($my_query) wp_reset_query(); //just in case ?>I’ve give both a try.
Forum: Fixing WordPress
In reply to: Will this code limit the posts displayed to the last 14 days?oh my god… you have SOLVED IT!
I owe you big time.
Forum: Fixing WordPress
In reply to: Will this code limit the posts displayed to the last 14 days?Thank you!
the function is returning 1 as the count however, even though there are many more. Any idea why?
Forum: Fixing WordPress
In reply to: Will this code limit the posts displayed to the last 14 days?I’m trying to use this function to display a COUNT of all posts published in the last 30 days, but not actually display the posts.
any hints on getting this done?
[moderated–bump removed. Please refrain from bumping as per Forum Rules]
Forum: Fixing WordPress
In reply to: need help counting number of new postsJust found this right here:
<?php $current_month = date('m'); $current_year = date('Y'); $countposts=get_posts("year=$current_year&monthnum=$current_month"); echo 'the count of posts' . count($countposts); ?>trying to modify it to count posts within 3 days instead of a whole month or year.
Forum: Fixing WordPress
In reply to: need help counting number of new postsNot completely sure how to implement it. I think I see it, I just don’t know how to blend them.
Here is what I WAS playing with, in case it’s of any help, even though its not at all what you were recommending and even though it just returns a 0. (cue wayne’s world… “I’M NOT WORTHY!”)
<?php function new_post_count(){ $new_count = 0; if ( (time()-get_the_time('U')) <= (3*86400) ) { // The number 3 is how many days to keep posts marked as new $new_count++; } echo $new_count; } ?>Forum: Fixing WordPress
In reply to: need help counting number of new postsperhaps modifying something like this?
<?php $count=0; $my_query = new WP_Query('year=2008'); while ($my_query->have_posts()) : $my_query->the_post(); $count++; endwhile; echo '2008 post count is ' . $count; ?>Forum: Fixing WordPress
In reply to: need help counting number of new postsThanks for the help, the article is a great read!
The problem though is that I don’t see how to get the total NUMBER of posts. I’ve found many examples on how to retrieve and DISPLAY posts from a date range or whatever. Getting the post count seems to be so hard to find!
Forum: Fixing WordPress
In reply to: need help counting number of new poststhanks for the tip!
I’m trying to incorporate that with the:
wp_count_posts();function, but i’m not sure how to go about it. I’m really new to PHP. I’ve got this function to mark a post as new with a div I’ve set up, but don’t think this will work for what I want. It checks if a post is within 3 days new and echoes my div:
function new_post_badge(){ if ( (time()-get_the_time('U')) <= (3*86400) ) { // The number 3 is how many days to keep posts marked as new echo '<div class="new"></div>'; } }perhaps I could set a variable in there instead of a div and have it add a 1 to it every time it runs the code?
Forum: Fixing WordPress
In reply to: need help counting number of new postsCan anyone help?
Forum: Fixing WordPress
In reply to: How do you add icons to your navigation?Anyone have any tips?
Forum: Fixing WordPress
In reply to: How do you add icons to your navigation?Hi Shane,
Sorry but that’s not what I meant. What I mean is I want to have a small image next to each one of my categories, eg. a small TV next to my “Media” category, a small iPod next to my “Electronics” category, etc.
How can I go about doing that?
thanks for you help.
F