advanced-custom-fields

advanced custom field not return back result

大憨熊 提交于 2019-12-10 12:33:33
问题 i am using advanced custom filed and i made custom author field (it could be Publisher Or Brand etc) now this author's name is not printing on product (Book) page . in custom field its for author's name slug is 'names' add_action( 'woocommerce_after_single_product_summary', "ACF_product_content", 10 ); function ACF_product_content(){ echo '<h2> ACF Content </h2>'; if (function_exists('the_field')){ echo '<p>Woohoo, the_field function exists! </p>'; //the_field('authors'); echo '<pre>'; print

Count how many rows are in sub_field

≯℡__Kan透↙ 提交于 2019-12-10 12:17:49
问题 I am using advanced custom field repeater to load some sub_fields which you can see in the below code: <?php if( get_field('who_made_it') ): ?> <div id="role-wrapper"> <?php while( has_sub_field('who_made_it') ): ?> <div class="role-item"> <?php the_sub_field('job_role'); ?> <?php the_sub_field('description'); ?> </div> <?php endwhile; ?> </div> <?php endif; ?> I would like to count how many .row-item 's there are and then print that number as a class on the container #role-wrapper . So as a

How to count the total number of rows in a ACF repeater output

时光毁灭记忆、已成空白 提交于 2019-12-10 04:10:35
问题 Question: How do you simply count the rows in the output of an ACF repeater field? Goal: to make the output look different with a css class when there's only one row, vs. more than one row. My code: if( have_rows('testimonials')) { $counter = 0; $numtestimonials = ''; //loop thru the rows while ( have_rows('testimonials') ){ the_row(); $counter++; if ($counter < 2) { $numtestimonials = 'onlyone'; } echo '<div class="testimonial ' . $numtestimonials . '">'; // bunch of output here echo '</div>

Display product post type advanced custom field on recent orders template and admin orders (woocommerce)

元气小坏坏 提交于 2019-12-10 01:01:02
问题 I’m trying to display the fields I have created in the recent order template of WooCommerce and I’m not very knowledgeable in PHP. I have created a field called sessions and registered as a product post type. Once a user purchase a product I want thats customs fields "sessions" values to be displayed in the My account > Recent orders (template). I tried looking for answers and solutions and I seem to be stuck. Here is the customized code of my-order.php template that I have been working on. I

merge_array returns null if one or more of arrays is empty?

江枫思渺然 提交于 2019-12-09 07:46:29
问题 I will give you quick run down of what I am doing. I am using wordpress with the advanced custom fields plugin. This is a php based question because these get_field() fields contain object arrays. $gallery_location = get_field('gallery_location'); $gallery_studio = get_field('gallery_studio'); For example $gallery_location when dumped will return this... array(18) { [0]=> array(10) { ["id"]=> int(126) ["alt"]=> string(0) "" ["title"]=> string(33) "CBR1000RR STD Supersport 2014 001" ["caption"

ACF Gallery Pagination in Worpdress

霸气de小男生 提交于 2019-12-08 12:39:08
问题 This is how I created my gallery using ACF Gallery field type. I successfully displayed all of the images, But I only want to display 4 images per page. I have an idea how to paginate a post type but I have no idea on how to paginate ACF gallery. Thanks! <?php $images = get_field('field_59f2a1869ef2b'); $size = 'full'; if( $images ): ?> <?php foreach( $images as $image ): ?> <?php echo wp_get_attachment_image( $image['ID'], $size ); ?> <?php endforeach; ?> <?php endif; ?> 回答1: Thank you for

Wordpress - filter admin user list with custom field (ACF)

元气小坏坏 提交于 2019-12-08 12:37:17
问题 I want to extend my view of users list by: adding sortable column based on custom field giving possibility of filtering list by custom field So what i've did: created custom field via ACF (its name is: opiekun_klienta) entered proper values via user settings (so i've picked one of the values from the list) I have such a piece of code: add_filter( 'manage_users_columns', 'column_register_wpse_101322' ); add_filter( 'manage_users_custom_column', 'column_display_wpse_101322', 10, 3 ); function

ACF conflict with Woo-commerce attribute

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-08 04:58:46
问题 I can't add attributes to products in woocommerce. It shows this error. select2.js:934 Uncaught Error: Option ‘ajax’ is not allowed for Select2 when attached to a element. 回答1: it is a Conflict with WooCommerce and select2.js. this error shows beacause woocommerce is updated i think this will solve your problem. add_action('init', function() { define('SELECT2_NOCONFLICT', true); }, 1); function my_acf_init() { acf_update_setting('select2_version', 4); } add_action('acf/init', 'my_acf_init');

WordPress query posts by ACF

大城市里の小女人 提交于 2019-12-07 18:19:46
问题 UPDATE - SOLVED Okay so I have three custom post types 'courses', 'modules' and 'results'. These post types are set up with a number of ACF (Advanced Custom Fields). I'm trying to query the 'results' CPT based on their ACF's using 'meta_query'. The two ACF fields I'm trying to query with are 'module' and 'user'. 'module' - Set up as a 'Relationship' field type filtering the 'module' custom post type. 'user' - Set up as a (Relational) 'User' field type. I seem to only get an empty array back.

Wordpress Gravity Forms get List values

≡放荡痞女 提交于 2019-12-07 12:00:55
问题 Can somebody point me in the direction on how to extract values from submitted forms containing list fields? I'm trying to create a front-end posting form using Gravity Forms, and then having the submitted values be assigned to custom fields made with Advanced Custom Fields. For normal fields, you can do this with the following: add_action("gform_after_submission_1", "acf_submission", 10, 2); function acf_submission($entry, $form) { $post_id = $entry["post_id"]; update_field('field_###',