Plotting posts on a graph

You can do that with a custom SQL query, something along the lines of: global $wpdb; $results = $wpdb->get_results( “SELECT DATE(post_date) AS d, COUNT(*) AS c FROM $wpdb->posts WHERE post_status=”publish” GROUP BY d” ); You’ll get an array of objects where d is the date and c is the number of posts published on that … Read more

Switch Categories on a Specific Date?

I don’t know if this can be accomplished with WP alone. I would create two custom fields for your posts. First custom field would hold the date you want make the switch Second field would hold the category you want the post to switch to (Assuming it’s not always the same post and not always … Read more

Show all 12 months regardless they have posts

I believe this is correct: $year = 2013; $month = 0; $qry = new WP_Query( array( ‘post_type’=>’post’, ‘posts_per_page’=>-1, ‘orderby’=>’date’, ‘order’=>’ASC’, ‘ignore_sticky_posts’ => true, ‘year’ => $year, ) ); while ($month < 12) { $month++; echo date(‘M’,strtotime(‘2000-‘.str_pad($month, 2, ‘0’, STR_PAD_LEFT).’-01 00:00:01′)).'<br>’; if ($qry->have_posts()) { while ($qry->have_posts()) { if (date(‘n’,strtotime($qry->post->post_date)) == $month) { echo ” — “; … Read more

Update post date of page when Visitor access that page?

You can hook into the action the_post (you get the post as parameter here) and run wp_update_post(). Make sure to clean up the date properties and not to run on the admin side or when a post is called in a widget: is_admin() or add_action( ‘the_post’, function( $post ) { if ( ! is_singular() or … Read more

Added Date Filter To Popular Posts Query

For creating a date filter you can use // Create a new filtering function that will add our where clause to the query function filter_where( $where=”” ) { // posts in the last 7 days $where .= ” AND post_date > ‘” . date(‘Y-m-d’, strtotime(‘-7 days’)) . “‘”; return $where; } add_filter( ‘posts_where’, ‘filter_where’ ); … Read more

Change News Story Layout Based on Date Range

Conceptually, that isn’t hard to do. if (have_posts()) { while (have_posts()) { the_post(); if ( $post->post_date >= date(“Y-m-d H:i:s”,strtotime(‘7/15/03 1:03 PM’)) && $post->post_date <= date(“Y-m-d H:i:s”,strtotime(‘9/19/07 11:34 AM’))) ) { // (layout coding) } elseif ( /* another condition */ ) { // (layout coding) } elseif ( /* another condition */ ) { // … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)