Adding custom fields to the header.php
Can you put the following code for displaying content of custom filed? <?php the_field(‘filed_name’); ?>
Can you put the following code for displaying content of custom filed? <?php the_field(‘filed_name’); ?>
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
You need to pass in the ID of the post you’re trying to get the field from: Eg get_field(‘display_featured_image’, $post_id). In a loop you could do get_field(‘display_featured_image’, get_the_id()); ACF Stores field data in wp’s meta_fields, so you could even use WP’s built in meta handler to pull the data yourself Eg: get_post_meta( $post_id, ‘acf_field_name’, true); … Read more
The get_field_object() function requires the field KEY not the field NAME. See docs: http://www.advancedcustomfields.com/resources/functions/get_field_object/ So it should looks something like this… $field = get_field_object(‘field_53d27f5599979’); $value = get_field(‘field_myfield’); $label = $field[‘choices’][ $value ]; You can find the field key by clicking on “Screen Options” > “Show Field Key” and it should appear next to the field … Read more
Note that I don’t have ACF PRO 5.8 which comes with the Block features, but I hope this answer helps. If you look at the example here, you can retrieve the additional/custom CSS classes using props.attributes.className; i.e. the classes are saved as an attribute named className. So with that in mind and based on acf_register_block() … Read more
The problem is that the function update_field from ACF works a little bit different from update_post_meta. Can you see it? update_post_meta( $post_id, $meta_key, $meta_value, $prev_value ); update_field( $field_key, $value, $post_id ); If you use update_post_meta you should in my opinion use get_post_meta to get the meta. If you use update_field you should use the_field or … Read more
There are many ways you could use to reach your goal. Here’s one… Steps: Create a shortcode that renders the form. Create and enqueue a JavaScript file that handles the form submission. Create PHP function for creating/updating Post/Custom Post. In your functions.php: /** * @return string $html HTML form. */ function shortcode__new_post_form() { /** * … Read more
Thank you so much for your post, I spent half day to figure out how to get field names by their group. If you have field names, you can easily get their values: get_field($field[‘name’]); EXAMPLE HOW TO GET IMAGES FOR SLIDER <?php //or insert the ID of your fields Group. $groupID=’116′; $custom_field_keys = get_post_custom_keys($groupID); foreach … Read more
I’m using a plugin called TurboCSV (found here, at the time of writing). The plugin offers support to add data to your various custom fields, which need to be created before the import takes place. In my personal use, I was able to successfully import thousands of items from one .csv, including hundreds of taxonomy … Read more
This solution works with get_items() in /lib/endpoints/class-wp-rest-posts-controller.php of the v2 WP Rest API. First, you’ll want to construct the GET arguments like you would for a new WP_Query(). The easiest way to do this is with http_build_query(). $args = array ( ‘filter’ => array ( ‘meta_query’ => array ( ‘relation’ => ‘AND’, array ( ‘key’ … Read more