advanced-custom-fields

Wordpress, Cache advanced custom fields or maybe other solution?

拟墨画扇 提交于 2019-12-13 10:26:22
问题 After having a hard time figuring out what plugin in my WordPress site causes a low page load speed, this happens to be the most important plugin ACF (advanced custom fields Pro). But I think I know the reason, I created a theme on my own that feet my needs, however in this theme the post loop load few ACF fields (and I just have to do that unfortunately ), the fields are loaded with the basic call function get_field() , but probably because this fields are inside the loop this causes a long

ACF front end form to create term

蓝咒 提交于 2019-12-13 05:45:11
问题 I want to use ACF frontend form function to create a form with custom fields that is used to create a taxonomy term, in this case a group. I have seen how to implement this with a post and have done so throughout the site but i am unable to implement this to insert a new term. I think i am on the right track but still am having issues with it not adding terms function my_pre_save_post( $post_id ) { // check if this is to be a new post if( $post_id != 'new' ) { return $post_id; } // Create a

ACF Header Background

瘦欲@ 提交于 2019-12-13 04:57:06
问题 I am using Advanced Custom Fields to display a background image in my header. Now I want to display a default image if there is no ACF-image defined. I tried this code, but it didn't work (image only shows if it is set): <?php wp_head(); ?> <?php if(get_field('header')) { $image = get_field('header'); } else { $image = '<img src="#absolute-path-to-my-image">'; } ?> <style type="text/css"> #inner-header{ background-image: url('<?php echo $image['url']; ?>'); background-position:center;

How to target an ACF field in a jQuery code inside à foreach loop?

江枫思渺然 提交于 2019-12-13 04:33:10
问题 How to target an ACF field in a jQuery code inside à foreach loop ? Currently, posts are looping in a foreach loop. Each post presents a coach with photo, title, small description and a phone number. All of this elements are ACF custom fields which need to be filled in a back-office for each person. At this point it's all right. Phone number of each coach is hidden, the user needs to click on a button (which is an image "Show Number") to see the phone (which is another image as well). I'm

register field with php acf not working

时光毁灭记忆、已成空白 提交于 2019-12-13 03:01:46
问题 i want to create custom field in my ACF plugin, but with PHP. So i tried the below function but nothing happened, can anyone please help me function register_custom_acf_fields() { if ( function_exists( 'acf_add_local_field_group' ) ) { // ACF Group: People acf_add_local_field_group( array ( 'key' => 'group_person_details', 'title' => 'Person Details', 'location' => array ( array ( array ( 'param' => 'post_type', 'operator' => '==', 'value' => 'person', ), ), ), 'menu_order' => 0, 'position' =

ACF Querying custom post types with taxonomies

眉间皱痕 提交于 2019-12-13 00:48:50
问题 I can query and display all custom post types, but when trying to query them based on taxonomy as well it will not work. Somebody please help! Taxonomy function add_action( 'init', 'create_project_type_taxonomies', 0 ); function create_project_type_taxonomies() { // Add new taxonomy, make it hierarchical (like categories) $labels = array( 'name' => _x( 'Project Types', 'taxonomy general name' ), 'singular_name' => _x( 'Project Type', 'taxonomy singular name' ), 'search_items' => __( 'Search

Sorting a repeater field from Advanced Custom Fields in PHP and Timber/Twig

。_饼干妹妹 提交于 2019-12-12 14:17:14
问题 I'm trying to sort the output of a repeater field from the WordPress plugin Advanced Custom Fields (ACF) using the WordPress Timber plugin implementation of Twig 1.34. The basic PHP example to sort from ACF below is from https://www.advancedcustomfields.com/resources/how-to-sorting-a-repeater-field/ and there are no usable answers for my question in the ACF forums. So I'm trying to convert this function from the example to Timber/Twig: // get repeater field data $repeater = get_field(

How to add a button to ACF tiny MCE editor

 ̄綄美尐妖づ 提交于 2019-12-12 14:16:23
问题 How can i add a button to ACF WYSIWYG editor ( for example 'text color' button ). i tried this code but it doesn't work :( add_filter( 'acf/fields/wysiwyg/toolbars' , 'dw_add_buttons_to_acf_wysiwyg_editor' ); function dw_add_buttons_to_acf_wysiwyg_editor( $toolbars ){ $toolbars['Full'][2][] = 'forecolor'; return $toolbars; } 来源: https://stackoverflow.com/questions/27462326/how-to-add-a-button-to-acf-tiny-mce-editor

WordPress Advanced Custom Fields Repeater, wrap every 3 divs in a row

孤者浪人 提交于 2019-12-12 09:56:14
问题 I'm using Advanced Custom Fields, and I would like to wrap every 3 divs in a row. If there is a fourth div or 2 extra then those would get wrapped in their own row. So open and close with a row. I currently have the basic output but all my current attempts to add the counter have failed. Any help would be appreciated <?php // wrap every 3 divs in a row if(get_field('triple_column_2')): ?> <?php while(has_sub_field('triple_column_2')): ?> <div class="col-sm-4"> <?php the_sub_field('copy'); ?>

Wordpress (ACF) function does not return a value

爱⌒轻易说出口 提交于 2019-12-12 05:41:56
问题 I am able to parse the data through the variable no problem, but the HTML output for my echo is not being wrapped properly. <? if( get_field('pre_video_set_label_name') ) { echo "<h3>" . the_field('pre_video_set_label_name') . "</h3>"; } else { echo "<h3>Post-Event Video</h3>"; } ?> If my input for pre_video_set_label_name is "Test" then the HTML output becomes: Test<h3></h3> My expected output would be: <h3>Test</h3> But I'm not getting these results. Nothing seems to wrap, and I've been