Compare WP Custom Field date

Take a look at meta.php:777: … CAST($alias.meta_value AS {$meta_type}) {$meta_compare} {$meta_compare_string})… So if you want to use DATE comparisons, you should use MySQL compatible date formats (YYYY-MM-DD). Change this part of your code: array( ‘key’ => ‘date’, ‘value’ => date(“Y/m/d”), ‘compare’ => ‘>=’, ‘type’ => ‘DATE’ ), to: array( ‘key’ => ‘date’, ‘value’ => date(“Y-m-d”), … Read more

How to Display ACF Relationship Custom Field as Link to Specific Custom Post?

Finaly, I make this working. I put this in my template: <?php $contacts = get_field(‘list_supplier’); ?> <?php if( $contacts ): ?> <?php foreach( $contacts as $contact ): ?> <a href=”https://wordpress.stackexchange.com/questions/118817/<?php echo get_permalink( $contact->ID ); ?>” target=”blank”><?php echo get_the_title( $contact->ID ); ?></a> <?php endforeach; ?> <?php endif; ?> And here is the filter I am using … Read more

How to use custom fields to enable sticky posts on custom post types?

You can achieve this with ACF. Create a custom field checkbox (just a simple boolean) for your custom post type. Below an example of overriding the main loop in archive template : function order_cpt_by_stickyness( $query ) { if(!is_admin() && $query->is_main_query() && is_post_type_archive(‘my_custom_postype’)) { $query->set( ‘meta_key’, ‘my_sticky_custom_field’); $query->set( ‘orderby’, [‘meta_value’ => ‘DESC’, ‘date’ => ‘DESC’]); } … Read more

WordPress Custom Field Should be Unique. Is it possible?

You can use the filter hooks ‘add_post_metadata’ and ‘update_post_meta’, when a function hooked there return anything but NULL the process of adding/updating metadata is stopped. The two hooks passes almost same args: NULL post id the meta key the meta value being added/updated Only last argument is different, in case of update is previous value, … Read more

How to add custom field to custom taxonomy in 4.4

You can implement this in two ways to add meta boxes through plugin or wordpress predefined hooks https://wordpress.org/plugins/taxonomy-metadata/ **OR** Add the following code in functions.php in your theme function mj_taxonomy_add_custom_meta_field() { ?> <div class=”form-field”> <label for=”term_meta[class_term_meta]”><?php _e( ‘Add Class’, ‘MJ’ ); ?></label> <input type=”text” name=”term_meta[class_term_meta]” id=”term_meta[class_term_meta]” value=””> <p class=”description”><?php _e( ‘Enter a value for this … Read more