How to query posts by month based on date custom field?

It is not clear what you’re using as a comparison, but WP Query supports meta query comparisons and even has a DATE type. For example: $query = new WP_Query( array( ‘post_type’ => ‘attraction’, ‘meta_key’ => ‘attraction_date’, ‘meta_value’ => ’10’, ‘meta_compare’ => ‘LIKE’, ‘type’ => ‘DATE’ ) ); Using 10 is not going to get you … Read more

Using global $post; with custom post types

How about this? (Add to your theme’s functions.php file, or to a plugin.) function new_post_alert() { global $post; $ageunix = get_the_time( ‘U’ ); $days_old_in_seconds = time() – $ageunix; $days_old = $days_old_in_seconds / 86400; $post_type = get_post_type(); if ( ( $days_old < 3 ) && ( ‘news’ === $post_type ) ) { ?> <script type=”text/javascript”> jQuery(document).ready(function($){ … Read more

How show post only from after custom date

You can do this using query_posts() or a new WP_Query object. Here’s an example: query_posts( array( ‘post_type’ => ‘my_post_type’, ‘meta_query’ => array( array( ‘key’ => ‘my_date_field_key’, ‘value’ => date( ‘d/m/Y’ ), ‘compare’ => ‘<‘, ‘type’ => ‘DATE’ ) ) ) ); if ( have_posts() ) : while( have_posts() ) : the_post(); // your loop code … Read more

Order posts by date

Three loops http://codex.wordpress.org/Class_Reference/WP_Query#Time_Parameters $time = time(); foreach ( range( 0, 2 ) as $yesterday ): // get relative time offset by $yesterday days $rel_time = strtotime( “-$yesterday days”, $time ); // get the digits $year = date( ‘Y’, $rel_time ); $day = date( ‘d’, $rel_time ); $month = date( ‘m’, $rel_time ); // get the … Read more

Changing date query from month

I’m kinda confused on why you’re passing 0 as meta_value, but if your storing unix timestamps under anniversary_date, this approach should be sufficient: // queries anniversary dates between today and the next 30 days $query = new WP_Query(array( ‘order’ => ‘ASC’, ‘orderby’ => ‘meta_value’, ‘meta_key’ => ‘anniversary_date’, ‘meta_value’ => array(strtotime(‘today’), strtotime(‘+30 days’)), ‘meta_compare’ => ‘BETWEEN’ … Read more

Date based CSS/theme

I php you can create an anchor class based on the desired date. I haven’t tested it, but it should be something like this: // your relevant html parent element <div class=”<?php echo getOlderPostsClassName( ‘5/5/2012’,the_time() ); ?>”> function getOlderPostsClassName($untilDate, $wordpressPostDate) { $start = strtotime($untilDate); $end = strtotime($wordpressPostDate); if ($start-$end > 0) { return ‘My_css_class_for_older_posts’; } … Read more

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