advanced-custom-fields

Wordpress ACF get_field( ) not returning value

笑着哭i 提交于 2019-12-05 08:06:55
I am using the advanced custom field plugin for Wordpress . I am having difficulty displaying a field on my page. Basically I've created a field group and assigned id's to the members of that group. I then use the get_field('field_name') function to store the value of this field in a variable and echo it on the screen. However this is returning false . I've also tried using the_field('field_name') but this returns null . I then read somewhere If you are trying to access a field outside of the Wordpress loop you must pass the post id as a parameter to the get_field()/the_field() methods. I've

Adding a character in the middle of a string

回眸只為那壹抹淺笑 提交于 2019-12-05 00:18:58
There's probably a simple solution to this that will cause a facepalm. I have time stored as a 4 character long string ie 1300. I'm trying to display that string as 13:00. I feel like there has to be a solution to this that is more elegant than what I'm doing at the moment. I currently have: $startTime = get_field($dayStart, $post->ID); $endTime = get_field($dayEnd, $post->ID); for ($x=0; $x = 4; $x++){ if(x == 2){ $ST .= ':'; $ET .= ':'; } else { $ST .= $startTime[x]; $ET .= $endTime[x]; } } $startTime = $ST; $endTime = $ET; The string will always be 4 characters long. Ethan $time = "1300";

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

孤者浪人 提交于 2019-12-04 23:31:10
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 have been hacking it for days and can't seem to display this values in my recent orders table. Updated

Meta Query Posts by Sub Field Value ACF

╄→гoц情女王★ 提交于 2019-12-04 15:32:23
I am attempting to query posts by those with sub field values of 'audi'. I have looked and looked but cannot find an answer. The $args I have are below, and posts exist in the database which match 'audi' as the value for sub field 'model' of repeater 'cars'. $args = array( 'post_type' => 'manufacturers', 'meta_query' => array( array( 'key' => 'cars_%_model', 'value' => 'audi', 'compare' => 'LIKE' ) ) ); $query = new WP_Query($args); Any hints as to where this code falls down would be really appreciated. I spent a few hours on this and have a solution for you: First thing you need to do is

POSTed arrays keep their values

让人想犯罪 __ 提交于 2019-12-04 06:56:40
问题 Today I noticed one of my Wordpress installations is behaving in a very strange way: whenever I update a post from the Dashboard, some of its extra inputs keep the values they already have (all of them are multi-dimensional arrays). For example: [post.php?post=123&action=edit] <input type="text" id="field_a0b" class="text" name="fields[a][0][b]" value="Current value" placeholder=""> If I edit that post manually (as an end user would), changing Current value to New value , then hit the Update

Wordpress: Archive page with Filter doesn't work (ACF)

回眸只為那壹抹淺笑 提交于 2019-12-04 06:32:43
Im trying to filter my custom post types by a checkbox field of ACF. I work with this tutorial: https://www.advancedcustomfields.com/resources/creating-wp-archive-custom-field-filter/ Now I got the problem that nothing change, when ich filter over the checkboxes on the archive page of the custom post type. It generates only the right URL but doesn't filter the posts. Does some have any idea why? function.php: // array of filters (field key => field name) $GLOBALS['my_query_filters'] = array( 'mitglieder' => 'mitglieder' ); // action function my_pre_get_posts( $query ) { // bail early if is in

Orderby ACF custom field date don't work

为君一笑 提交于 2019-12-04 05:20:02
问题 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 ? 回答1: I have updated your code .Please try your

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

折月煮酒 提交于 2019-12-03 09:39:37
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"]=> string(0) "" ["description"]=> string(0) "" ["mime_type"]=> string(10) "image/jpeg" ["url"]=>

POSTed arrays keep their values

烈酒焚心 提交于 2019-12-02 14:01:16
Today I noticed one of my Wordpress installations is behaving in a very strange way: whenever I update a post from the Dashboard, some of its extra inputs keep the values they already have (all of them are multi-dimensional arrays). For example: [post.php?post=123&action=edit] <input type="text" id="field_a0b" class="text" name="fields[a][0][b]" value="Current value" placeholder=""> If I edit that post manually (as an end user would), changing Current value to New value , then hit the Update button, $_POST['fields']['a'][0]['b'] will still contain Current value - not New value as I would

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

早过忘川 提交于 2019-12-02 13:52:11
问题 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