Query posts from current year

You just need get current date and add it on data_query in wp_query, Look this: <?php $getdate = getdate(); $args = array( ‘date_query’ => array( array( ‘year’ => $getdate[“year”] ), ), ); $query = new WP_Query( $args ); ?> and then use loop: <?php if ( $query->have_posts() ): while ( $query->have_posts() ) : $query->the_post(); the_title(); … Read more

How to show the real post date in a draft

Yes, as you – so far – have no publish date. You could use $post->post_modified, which will always be the date of the latest modification to the post data. Debug: Try hooking into the filter and dump both vars: function date_dump_callback( $date, $d ) { echo ‘<pre>’; print_r( $date ); print_r( $d ); echo ‘</pre>’; … Read more

Uploading DB to server from local is not matching the post dates

WordPress uses the date_default_timezone_set() function to set the server timezone. This is based on the timezone offset setting under Settings->General. Check your setting to make sure it matches your timezone at: http://yourdomain.com/wp-admin/options-general.php If changing your timezone via the setting doesn’t work, there’s probably nothing you can do to change this without touching your server configuration. … Read more

Rearranging posts based on categories

May be it’s a bad idea, but it’s the only. Don’t print posts immediately, but collect them in different variables: one for category “test”, one for the rest. <?php $w_h = $w_d = $last = 0; // init variables to concatenate content later $primary_posts = $secondary_posts=””; // empty array to fill later $category_names = array(); … Read more

Page permalink conflict with Date

First of all rewrite handling can become very complicated very quickly – particularly when your desired structure conflicts with WordPress’ default behaviour. The best advice is probably to just avoid such conflicts rather than try to resolve them. With that as a premable… WordPress generates rewrite rules from various sources: from registered post types, rules … Read more

Metabox date month number to word

The code you are using is specifically for the month abbreviation, (Oct). You should be using this: function eventposttype_get_the_month($month) { global $wp_locale; for ( $i = 1; $i < 13; $i = $i +1 ) { if ( $i == $month ) $month =$wp_locale->get_month( $i ) ; } return $monthabbr; }

Preventing 404 error on empty date archive

You can move the code from OP’s answer into a 404 template filter and force WP to load the date.php file instead of 404.php. It’ll still send the 404 header, but render the page with a different template. function wpd_date_404_template( $template=”” ){ global $wp_query; if( isset($wp_query->query[‘year’]) || isset($wp_query->query[‘monthnum’]) || isset($wp_query->query[‘day’]) ){ $template = locate_template( ‘date.php’, … Read more

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