i am using wordpress 4.1 with ACF v4. I have a custom post type with custom fields added and need add a new custom field each time a new category is added. If i add the category "Sedan" automaticly i have to add the custom field "Sedan". Can I do this with the plugin functions? Or I have to do this with code, with inserts in database? Thanks in advance!!
If you are trying to create a dynamically built category selector within ACF, look into the Taxonomy Field.
This will generate a list based on specified taxonomy (categories is an option). The field will return either the Taxonomy Term object (if you use a single select option such as radio buttons), or an array of objects (if you use a multiselect option such as checkboxes). You could also set the field to return the Term ID instead.
Related
In WooCommerce, I would like to display a table on a custom page with a list of (downloadable) products with their title and attribute / custom field values.
For the product title in the first column of my table I'm using the following shortcode:
[product _name id="9"]
The code in my funcions.php file
function displayProductName($item) {
$productName = get_the_title($item['id']);
return $productName;
}
add_shortcode('product_name', 'displayProductName');
In the second column I'd like to display the value of a custom added field (with advanced custom fields): field is File Version (slug file-version), value is 1.22
I can't seem to figure out how to translate this into a working function.
So what I would like is to display the value of a custom field based on a single product ID on a random page with a shortcode.
Any ideas would be very appreciated.
After doing more research, I managed to find the solution, which was much easier than I thought.
Since I'm using Advanced custom Fields, I could use their shortcode.
So for example, I have custom field Download Version (slug: download_version) that I use for downloadable products.
To display the value of Download Version for a specific product, on a random page, I used the shortcode
[acf field="download_version" post_id="9"]
Where the product ID is 9.
Maybe useful for other users who want to do the same...
I'm using WooCommerce and Advanced Custom Fields on my WordPress website.
I want to add Advanced Custom Fields to WooCommerce API to get custom field value for each product.
How can I do it ?
Thanks
What you could do is the following
Go to Custom Fields and create a new field group - add in whatever data you need for the products and then, most importantly, in the location section ("Show this field group if") select to display the field group is equal to product from the drop down.
Then the field group will display when you have any product open.
I am trying to create a checkbox array for use in WordPress Advanced Custom Fields so that the user can select multiple values when he creates a post. The checkboxes should be created from another custom post type called Features (use field = "feature-name").
How would I go about doing this?
I had Taxonomy category that must had such opportunity to add multiple fields from admin panel and get them like the picture.So for example what i can create that will give the user opportunity to add the fields dynamically and how can I get their values?
I found a solution and used plugin Custom Field Suite
It has a field type Loop and it was what I needed to add how many how needed.
How can I define default custom fields list in wordpress?
I want to give users ability to choose custom fields from list when they create or edit post in admin. On that coustom fields I will base design and make different styles when users choose "youtube" or "image". It's impossible to find any solution for that simple problem in web.
WordPress takes existing custom fields and presents them in a select box. So, once you've created a custom field once on one page it will be available on all pages in the WP Admin. Just click "Enter New" about the Custom Field select box and it will allow you to enter in a new meta key.
More Technical
Custom Fields are stored in your Metadata database table, whereas the custom field name is the meta_key and the custom field value is the meta_value.
When an edit page loads it take a grouping of all custom fields (minus fields that are used for internal use) and presents them in the select drop down.
Retrieving
Retrieving a custom field would be as follows:
$custom_field = get_post_meta($post->ID,"CUSTOM FIELD NAME",true);
Predefined Custom Fields
WordPress offers a popular plugin Advanced Custom Fields that allows you to create different types of custom fields with preset values. This helps content editors to choose the appropriate value attached with the appropriate custom field.