advanced-custom-fields

Can't assign the value of the_field() to a variable

寵の児 提交于 2019-12-02 09:38:05
问题 I'm using Advanced Custom Fields in Wordpress. I have a file path in a field (say "submenu/abc.php" in field "ACFfield"). I want to include that info on a webpage. If I do: <?php include "submenu/abc.php" ?> This works fine. But I need to do something like: <?php $file = the_field(ACFfield); include($file); ?> This, however just prints out "submenu/abc.php", from the first line (which I wouldn't want visible anyway). What am I doing wrong? 回答1: the_field(ACFfield); doesn't return anything. It

Is it possible to query posts in the same order as assigned?

我与影子孤独终老i 提交于 2019-12-02 03:47:40
I have a custom field named type , which is a a "radio button" data type and it has some choices. This custom field, is assigned to a custom post type named pproduct . For example here are the choices of this custom field : RED BLUE YELLOW WHITE BLACK Only one can be selected from the above. The below $args : $args = array( 'post_type' => 'pproduct', 'posts_per_page' => -1, 'post_status'=>array('publish'), 'product' => $category->slug , 'meta_query' => array( 'relation' => 'AND', 'type_clause' => array( 'key' => 'type', ), 'order_clause' => array( 'key' => 'order', ), ), 'orderby' => array(

Can't assign the value of the_field() to a variable

谁说我不能喝 提交于 2019-12-02 03:46:18
I'm using Advanced Custom Fields in Wordpress. I have a file path in a field (say "submenu/abc.php" in field "ACFfield"). I want to include that info on a webpage. If I do: <?php include "submenu/abc.php" ?> This works fine. But I need to do something like: <?php $file = the_field(ACFfield); include($file); ?> This, however just prints out "submenu/abc.php", from the first line (which I wouldn't want visible anyway). What am I doing wrong? the_field(ACFfield); doesn't return anything. It just prints the filename out. Use get_field() instead, which will return the value. 来源: https:/

Orderby ACF custom field date don't work

风流意气都作罢 提交于 2019-12-02 03:15:33
I view the other post but I found nothing, I'm on since 3 days : I want display 3 'evenements' in the order ASC but 2018 is always before 2017 $auj = date('Ymd'); $queryEvent = new WP_Query( array( 'category_name' => 'evenements', 'posts_per_page' => 3, 'meta_key' => 'date_de_fin', 'orberby' => 'meta_key', 'order' => 'ASC', 'meta_query' => array( array( 'key' => 'date_de_fin', 'value' => $auj, 'compare' => '>=', ), ) ) ); ?> someone has an idea ? I have updated your code .Please try your updated query. <?php $auj = date('Ymd'); $queryEvent = new WP_Query( array( 'category_name' => 'evenements'

Displaying Advanced Custom Field (ACF) value in a WooCommerce hook

对着背影说爱祢 提交于 2019-12-01 11:36:18
I want to display the value from an Advanced Custom Field (ACF) in Woocommerce and I am using this code in this function hooked: add_action( 'woocommerce_single_product_summary', 'charting', 20 ); function charting() { if( get_field('size_chart') ) { echo '<p><a href="'.the_field('size_chart').'" data-rel="prettyPhoto">size guide</a></p>'; } return; } But it is not working, it is displaying the custom field value above the href (size guide) and the href is empty like this: <a href="" data-rel="prettyPhoto">size guide</a> Your problem is that you can't use echo with ACF the_field('my_field') ,

Displaying Advanced Custom Field (ACF) value in a WooCommerce hook

跟風遠走 提交于 2019-12-01 08:37:26
问题 I want to display the value from an Advanced Custom Field (ACF) in Woocommerce and I am using this code in this function hooked: add_action( 'woocommerce_single_product_summary', 'charting', 20 ); function charting() { if( get_field('size_chart') ) { echo '<p><a href="'.the_field('size_chart').'" data-rel="prettyPhoto">size guide</a></p>'; } return; } But it is not working, it is displaying the custom field value above the href (size guide) and the href is empty like this: <a href="" data-rel

Output a product custom field in WooCommerce Order Admin Page (ACF)

青春壹個敷衍的年華 提交于 2019-12-01 02:10:19
With WooCommerce, I'm using the Advanced Custom Fields plugin to keep a track of where I physically store each product. When an order comes in, I want to be able to look at the admin edit order page and see where the items are stored. So I can grab it to ship. Here's a picture of what I want to see: Hopefully, it makes sense. I just want to recall the individual product ACF variable (BinLocation) for each product on the Edit Order Admin Page for Wordpress. Any help on this? Thanks. Updated: Using a custom function hoocked in woocommerce_before_order_itemmeta action hook, you will be able to

Insert PHP code into the Visual Composer

被刻印的时光 ゝ 提交于 2019-12-01 01:46:46
I have the php code (ACF Pro plugin code). How can I insert this code into my Visual Composer? Can't find the solution for a long time but now it's critical for me. <?php if( have_rows('add_a_new_table') ): ?> <?php while( have_rows('add_a_new_table') ): the_row(); // vars $t_title = get_sub_field('t_title'); $t_pricing = get_sub_field('t_pricing'); $t_emails_number = get_sub_field('t_emails_number'); ?> <div class="col-sm-12 col-sm-4 text-center"> <div class="courses-column"> <div class="courses-column-inner"> <h3><?php echo $t_title; ?></h3> <p style="font-size: 24px;"> <?php echo $t_pricing

Change Google Maps marker icon when clicking on other

*爱你&永不变心* 提交于 2019-11-30 20:17:45
I have created a Google Maps Multiple locations page, using Advanced Custom Fields Google Map field. I have managed to make the marker icon change when clicked on, but I want it to be changed back when clicking on other icons. here is an example of the code: for (i = 0; i < locations.length; i++) { marker = new google.maps.Marker({ position: new google.maps.LatLng(locations[i][1], locations[i][2]), map: map, icon: iconBase + 'Stock%20Index%20Up.png' }); google.maps.event.addListener(marker, 'click', (function(marker, i) { return function() { infowindow.setContent(locations[i][0], locations[i]

Wordpress ACF: How to add rows to a repeater field attached to a user via custom code (PHP)

孤街醉人 提交于 2019-11-30 06:58:26
I have been through the ACF and ACF Repeater Field documentation but it has left me a little bit confused. I have a bunch of users and I have (through ACF) attached a repeater field to each of them (called Events), the repeater field has a sub-field called Event ID (event_id). Now the dilemma I have is that I want to be able to add and remove rows of event_id from the user depending on which events they have tried to add and remove. I know of the update_field($field_key, $value, $post_id) function but I'm not too sure how to utilise it to add rows into sub-fields of a repeater field attached