Custom Post Types – How to include custom fields

@vemuez you need to enqueue js and css files to admin_print_script and admin_print_style here is the example to how to do it // Register datepicker ui for properties function admin_homes_for_sale_javascript() { global $post; if($post->post_type == ‘homes-for-sale’ && is_admin()) { wp_enqueue_script(‘jquery-ui-datepicker’, WP_CONTENT_URL . ‘/themes/yourthemename/js/jquery-ui-datepicker.min.js’); } } add_action(‘admin_print_scripts’, ‘admin_homes_for_sale_javascript’); // Register ui styles for properties function admin_homes_for_sale_styles(){ … Read more

How can I change the way dates shown in the archive widget?

For archives you can use the get_archives_link filter like this: add_filter(‘get_archives_link’, ‘translate_archive_month’); function translate_archive_month($list) { $patterns = array( ‘/January/’, ‘/February/’, ‘/March/’, ‘/April/’, ‘/May/’, ‘/June/’, ‘/July/’, ‘/August/’, ‘/September/’, ‘/October/’, ‘/November/’, ‘/December/’ ); $replacements = array( //PUT HERE WHATEVER YOU NEED ’01.’, ’02.’, ’03.’, ’04.’, ’05.’, ’06.’, ’07.’, ’08.’, ’09.’, ’10.’, ’11.’, ’12.’ ); $list = preg_replace($patterns, … Read more

Making next_posts_link(); return posts by month

You have to modify the query that selects the posts to select by month. This bit of code placed in the template will get the page number and subtract that from the current month. <?php $page = get_query_var(‘paged’) ? get_query_var(‘paged’) : 1; $subtractor = $page-1; $date = date(“Y-m-d H:i:s”); $current_month = date(‘n’, strtotime($date.’-‘.$subtractor.’months’)); $current_year = … Read more

How to get the date dynamically from archive.php to date.php?

It’s working very fine after I made some changes / adding on two php files function.php and date.php function.php function wpa_date_posts_per_page( $query ) { if ( !is_admin() && $query->is_date() && $query->is_main_query() ) { $query->set( ‘posts_per_page’, -1 ); } } add_action( ‘pre_get_posts’, ‘wpa_date_posts_per_page’ ); date.php <?php get_header(); while (have_posts()) : the_post(); echo the_title() . ‘<br/><br/>’; endwhile; … Read more

Archive filtering posts by year and month

That’s trivial, we can exploit how WordPress URLs work and pass the query vars directly in the URL: <form action=”/” method=”GET”> <select name=”year”> <option value=”2017>2017</option> … etc .. </select> <select name=”month”> <option value=”01>01</option> … etc .. </select> <input type=”submit” value=”Filter”/> </form> WP will then see that it’s a date archive, it may even 301 redirect … Read more

WordPress returns a wrong date

As mmm said, wp stores all dates&times in gmt, but will show times as per the setting timezone. So you can cgange the timezone without the history needing to be updated. I prefer to use the php datetime when working with time. Gives better control and flexibility, eg if you want to show events in … Read more