get_field not displaying my custom field value
Nevermind, I figured this out. The id needs to be “category_” and then the ID. So the code is: $sub_heading = get_field(“sub_heading”, “category_” . $cat->term_id);
Nevermind, I figured this out. The id needs to be “category_” and then the ID. So the code is: $sub_heading = get_field(“sub_heading”, “category_” . $cat->term_id);
I sorted this out, $post should be $p in: global $post; $product = new WC_Product( $post->ID );
See add_meta_box which has a lot of demo code for working with meta fields. Here is the most relevant part for you: /* Do something with the data entered */ add_action( ‘save_post’, ‘myplugin_save_postdata’ ); /* When the post is saved, saves our custom data */ function myplugin_save_postdata( $post_id ) { // First we need to … Read more
If ACF (or any other plugin) is active on the site you do not need to include its files as they are all being included in the wordpress initialization process. The only tricky part is that you don’t know the order in which files are included and yours might be included before the ACF files … Read more
I think you’re looking for this field: http://www.advancedcustomfields.com/resources/field-types/post-object/ It should allow you to choose any registered custom post type.
You can provide your own implementation of wp_trim_excerpt which is responsible for trimming and stripping HTML tags (it uses wp_strip_all_tags), By copying the function source code and applying the change that you want (which is keeping the <p> and <strong> tags (or any additional tags as you wish) and it will work nicely. I copied … Read more
This can be solved using this nice snippet and edit_form_after_title hook. But I haven’t tested what happens when more than one meta box exists. With a single ACF field (position:normal, style:no-metabox) it works: add_action( ‘edit_form_after_title’, ‘pre_title_metabox_wpse_94530’ ); function pre_title_metabox_wpse_94530() { global $post, $wp_meta_boxes; do_meta_boxes( get_current_screen(), ‘normal’, $post ); unset( $wp_meta_boxes[‘post’][‘normal’] ); } And if it … Read more
Try an array of arrays in your meta query. $args = Array( ‘post_type’ => ‘event’, ‘posts_per_page’ => -1, ‘meta_key’ => ‘event_date’, ‘orderby’ => ‘meta_value_num’, ‘order’ => ‘ASC’, ‘meta_query’ => array( array( ‘key’ => ‘event_date’, ‘compare’ => ‘>=’, ‘value’ => intval(strtotime(date(‘Y-m-d’))), ‘type’ => ‘numeric’ ) ), ); $query = new WP_Query( $args );
Yes, it is possible. And there’s an easy guide here. Below is a working code you can add to the theme’s main functions.php file: // Adds a custom rule type. add_filter( ‘acf/location/rule_types’, function( $choices ){ $choices[ __(“Other”,’acf’) ][‘wc_prod_attr’] = ‘WC Product Attribute’; return $choices; } ); // Adds custom rule values. add_filter( ‘acf/location/rule_values/wc_prod_attr’, function( $choices … Read more
This should get you started: <?php $the_query = new WP_Query( array( ‘post_type’ => ‘kalender_item’, ‘post_status’ => ‘publish’, ‘meta_key’ => ‘kalender_item_datum’, ‘orderby’ => ‘meta_value’ ) ); # This will hold what group we’re in $current_header=””; # The Loop while ( $the_query->have_posts() ) : $the_query->the_post(); # get the datum for this post $temp_date = get_post_meta( get_the_ID(), ‘kalender_item_datum’, … Read more