
Ah okay..
well there’s some information on creating your own field type here:
http://www.advancedcustomfields.com/resources/creating-a-new-field-type/
Other than that it sounds like you’re just creating a good old regular plugin.
More info on using ACF in your own plugins here:
http://www.advancedcustomfields.com/resources/can-include-acf-pro-within-theme-plugin/
Is that enough info?

That’s seriously wierd.. I think it’s got more to do with how WP has created the image than ACF.. it’s probably something gone wrong when uploading the images or something.
But in any case.. you do not need to add the width and height parameters of an img element. It’s perfectly fine leaving them out!
So just go ahead and remove those and you’ll be fine!

Ah okay.
Well I don’t see what exactly you want.
The update_field will work as long as there are actual fields to the content you want to add them to, they don’t need to already have content.
And to create fields completely from scratch you’d use the PHP functions already available like acf_add_local_field().
There’s no point in a insert_field() function as it would either do the same as acf_add_local_field() or just add meta to content. In the latter case it wouldn’t be helpful since there’s no actual ACF field to go with it.
There is however a plan to create a new api function for inserting new rows into a repeater or flexible field. That is currently a bit tricky (but doable) and it will be much easier!

Ah okay.
Well ACF works just fine I promise you 🙂
What it does is create a firm API and GUI in the admin area to create custom meta content for posts, users, terms you name it.
ACF does *not* add any content to your theme automatically. It does not create slideshows (altho you can use it to create slideshows on your own).
It’s basically a way to add meta content in WordPress without having to write all the code yourself.
To do this you go to the menu “Custom fields” from the main navigation in wp-admin. Click on a field group and in there you’ll find the fields belonging to that group.
You say there’s a custom field called home slides in the editor? do you mean in the actual editor or on the edit screen of the home page?

Okay,
Don’t know wether your issue is solved or not then?

Ah..
Well that’s fine. the acf field can be called whatever..
Your issue tho is that you’re using the ACF fieldname in your tax query for the taxonomy parameter when you should be using the taxonomy slug year.
Change that and it should work.

Okay,
that might save the values to the post but if you don’t have any fields that are actually using those values you wont see them in wp admin.


Hi @et3rnal
Not really getting it? You’re creating an add on for ACF with a new field type?
Or are you creating an add on without field types that isn’t really an addon for ACF but rather a plugin that utilizes ACF for its meta?

Okay.. when you say it’s shared.. do you mean that you’ve registered the taxonomy for the post type?
Because I believe you have to register the taxonomy for the post type as well (it would make the native meta box appear). Otherwise ACF can’t mapp the terms selected.

Hi @mefisto
There’s a whole documentation about creating new field types:
http://www.advancedcustomfields.com/resources/creating-a-new-field-type/
That should get you started 🙂
Best of luck!

Hi @weehong
There’s actually an easier way to do this using wp_query and the posts_where filter.
You can find an example here:
http://www.advancedcustomfields.com/resources/query-posts-custom-fields/
under the headline “4. Sub custom field values”

Hi @bill
You can do this by hooking into acf/save_post action hook. Then just retrieve your newly saved meta field and modify the post title using wp_update_post.
http://www.advancedcustomfields.com/resources/acfsave_post/
You might also want to read up on wp_update_post here and specifically the Avoid infinite loop section since that will be applicable to your situation.
https://codex.wordpress.org/Function_Reference/wp_update_post

If you’re not too concerned with being able to select the “wrong” years for a model you could just create a taxonomy field to go along with the model post object field in the repeater. Then as you loop through the info on the frontend you’d just output the model post object field and the years selected with that.
Another way would be to also connect the years taxonomy to the parts CPT and just select the years as a regular taxonomy meta box (not sure if that works with your setup.. not that good at autoparts).

Hi @eli
You could add the number as a value in the shortcode [shortcode number=2] and then in the shortcode function instead of doing a have_rows loop you can save the entire field to a variable and fetch the correct row based on the number.
$flexible_field = get_field('layout_element_inserter');
You’d have to of course look for the correct index of the specific layout type and not just grab the index right of the array.
This entire workflow seems a little backwards to me tho.. Why not just have the flexible field on the pages and create all the content right there in the order you want it. If you like you can even completely ditch the regular editor and just use a flexible field layout with an editor as a substitute.
You could achieve the same front end result or even better since you can also wrap editor content in its own html.

Hi @webjuice
Does it not work if you set max and min rows in the repeater fields settings in wp admin?

Hi @donnafefe
That’s because whenever you try to fetch something from content that’s not a post type you need to specify the second parameter. For taxonomy terms that would be like taxonomyslug_termid.
get_field_object($fieldkey, $category->taxonomy . '_' . $category->term_id);

Hi @danbo
You can simply do a count on the relationship field.
<?php echo $movie_count = count(get_field('movies_of_this_producer')); ?>

Hi @rthomas98
I don’t understand the question. It seems you’ve answered it yourself with the code you posted?
Or are you saying the code is not working?

Hi @spacedragon
You could simply wrap the functions in an if statement checking the current blog id 🙂
<?php if( get_current_blog_id() == 1 ){
echo 'This would only show on the first blog (the primary)';
} ?>

Hi @bela
I think you want to have a look at this documentation:
http://www.advancedcustomfields.com/resources/register-fields-via-php/
You can create fields and fieldgroups dynamically with PHP using that API.
You can also create your own acf-json file as well and save in the theme if you prefer that.
http://www.advancedcustomfields.com/resources/local-json/

Hi @marek-234
Hmm.. what return value have you set for the image field?
You could just set it to return an image object then do this:
<?php $image = get_field('photo_1'); ?>
<img src="<?php echo $image['sizes']['large']; ?>" width="<?php echo $image['sizes']['large-width']; ?>" height="<?php echo $image['sizes']['large-height']; ?>" alt="<?php echo $image['alt']; ?>" />

Hi @3primt-tony
So is it a repeater field? How are the slides created in admin?
You say you updated the plugin. To what version and from what version?

Hi @jsilver
Don’t have any performance benchmarkings for the difference but I would imagine they’re not much different there unless you get it up to insane quantities.
Personally if it’s fields not within a theme I would always go for the PHP approach. That’s because it’s more straight forward, I find the syntax easier to work with and most importantly it’s dynamic.
I have a project right now where I create ACF fields in a plugin dynamically based on posts in a CPT using the PHP method 🙂

Hi @philby
Have you set the taxonomy field to map to the post? check the create terms, save terms and load terms settings in the field settings.
Otherwise the taxonomies you select there will just be a meta value on the post. you could still query on it but it would be a meta_query.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.