advanced-custom-fields

How to expose all the ACF fields to Wordpress REST API in both pages and custom postypes

别来无恙 提交于 2020-02-19 07:00:48
问题 I want to expose all the ACF fields that belong to a page or custom post type to the WordPress REST API in order to do some API calls through javascript. The final expected result would be all the ACF fields inside an ACF object that you can easily access. 回答1: Through the following code, you will be able to expose page and your custom postypes ACF fields in the wordpress REST API and access them inside the ACF object. You can obviously customise the postypes to exclude or to include in the

Populate ACF Fields using Wordpress Rest API JS

限于喜欢 提交于 2020-01-30 12:09:54
问题 I'm new working with WordPress and I'm playing around with the Advanced Custom Fields plugin. It seems nice but I'd like to know if it's possible to POST a new object (created using ACF ) through the WordPress REST API ? I'm already using it to GET all my custom objects (thanks to ACF to REST API Plugin ). I'm using WordPress as my backend and NextJS as the frontend so I'd like to create a new HTML form, where the user can input some info and directly create an instance of that object. If it

Show post if true/false is yes. Advanced custom fields

大兔子大兔子 提交于 2020-01-25 22:04:49
问题 I have managed to get my loop to show only the posts that display true on an advanced custom field. But I now only want to show one post. I cant seem to get it to only loop one of the posts that features the true/false field as yes. 'posts_per_page' => '1' Doesn't work as it only shows the latest post.. which if its not ticked it just shows blank. <?php $args = array( 'post_type' => 'event' ); $the_query = new WP_Query( $args ); ?> <?php if ( have_posts() ) : while ( $the_query->have_posts()

Show post if true/false is yes. Advanced custom fields

我的未来我决定 提交于 2020-01-25 22:04:22
问题 I have managed to get my loop to show only the posts that display true on an advanced custom field. But I now only want to show one post. I cant seem to get it to only loop one of the posts that features the true/false field as yes. 'posts_per_page' => '1' Doesn't work as it only shows the latest post.. which if its not ticked it just shows blank. <?php $args = array( 'post_type' => 'event' ); $the_query = new WP_Query( $args ); ?> <?php if ( have_posts() ) : while ( $the_query->have_posts()

How to count items in an array that's in an array?

倾然丶 夕夏残阳落幕 提交于 2020-01-24 22:00:11
问题 How do you count items in an array that's part of an array? I'm using Advance Custom Fields plugin in WordPress and my array print_r(get_field('irl_today_entry')) output looks like this: Array ( [0] => Array ( [acf_fc_layout] => irl_today_website_entry [irl_today_website] => Array ( [0] => Array ( data removed) [1] => Array ( data removed ) ) ) [1] => Array ( [acf_fc_layout] => irl_today_social_entry [irl_today_social] => Array ( [0] => Array ( data remove ) [1] => Array ( data remove) ) ) )

Display checkboxes values from ACF (Wordpress) on front

荒凉一梦 提交于 2020-01-17 16:38:08
问题 I'm having some trouble trying to display checkboxes values created with ACF. I have a group of 12 checkboxes made with ACF, where each checkbox is a month: jan : Jan / feb : Feb / mar : Mar / etc. What i need to achieve is to display all of those 12 values in the frontend, with a particular CSS class if the month has been checked in the backend. For example, if the user checks "Jan", "Apr", "Jul" and "Sep": <span class="selected">Jan</span> <span>Feb</span> <span>Mar</span> <span class=

Advanced Custom Fields & Admin Color Schemer; change color of ACF buttons

人盡茶涼 提交于 2020-01-17 07:27:33
问题 I use Admin Color Schemer to style my customers' WordPress admin panel, but it doesn't affect the buttons from Advanced Custom Fields' custom fields. How would I change the plugin to include these buttons? 回答1: You can set a custom styling on the admin panel through the admin-bar.css stylesheet, which you can find in your WP installation under /wp-includes/css/admin-bar.css 来源: https://stackoverflow.com/questions/41366193/advanced-custom-fields-admin-color-schemer-change-color-of-acf-buttons

put default image if there is no image using ACF

三世轮回 提交于 2020-01-07 02:21:30
问题 I am using Wordpress ACF plugin and I have custom products section and I put a custom field for featured image and it's working perfect. Now I want if there is no featured image inserted then show a default image, I am using the following code but its not working. <? php $category_image = get_field('fimage'); if ($category_image) { $category_image_url = $category_image['sizes']['product-thumb']; } if ($category_image_url) { ?> <img src="<?php echo esc_url( get_template_directory_uri() ); ?>

How to fix a jQuery code looping incorrectly in a PHP foreach loop

白昼怎懂夜的黑 提交于 2020-01-06 05:50:14
问题 I'm trying to loop a piece of jQuery code inside a foreach loop. Each article in the loop have a phone number custom post type related (ACF). At this point the loop works well. As you see, the jQuery code only replace an image to another while user clicks in order to show the number (Ex : "Display Phone Number" image, becomes "555-555-1234"). The problem is that when I click in any image to display number...all articles show their phone number at the same time. I think is an ID problem in my

Display value from ACF field in Woocommerce order email

↘锁芯ラ 提交于 2020-01-05 09:14:56
问题 I´m trying to display a value for delivery date in the emails that Woocommerce automatic sends to the customer when the order is being processed. I have created a Advanced custom field value called 'leveranstid' and I want it to be shown with every product in the email. I´ve tried to add the code below to the functions.php but it doesn´t seem to work. Nothing shows. I would be very grateful if someone please help me find what´s wrong? add_action( 'woocommerce_order_item_meta_start', 'ts_order