Thanks @hube2!
I’m going to mark this as solved. My specific question requires some custom dev work and this at least helps me get started.
If I do end up making this as a plugin or I have a function that’s working I’ll be sure to drop this into the thread for anyone who’s interested.
And one day.. maybe one day… we can bring real fuzzy search to ACF.
🤞
Cheers! — Dan
@jtotheroc, I believe if you set the minimum number of allowed rows to 1, it will start the user off with that. I use this feature quite a bit and that’s how I got around it.
Elliot,
This is overdue but I found an issue to this problem.
It comes from the max_input_var
located in the php.ini file.
I’m using PHP v 5.4.4 which required adding the following line to the php.ini file to support saving fields that exceed the default limit. I’m not sure what the default is but here’s what I’m using now.
max_input_var = 100000
Source: http://stackoverflow.com/questions/10303714/php-max-input-vars
Hi @thesrpr,
There is a similar thread here, but instead of <br> it’s the p tag: http://support.advancedcustomfields.com/forums/topic/removing-paragraph-tags-from-wysiwyg-fields/
There are a few filters for this but what I’d recommend is reading up on the preg_replace
php function.
Here’s an example of how I removed p tags and empty spaces with that function:
<?php echo preg_replace('~\s?<p>(\s| )+</p>\s?~', '', get_sub_field('field_name')); ?>
You’d need something along these lines:
<?php echo preg_replace('/(<br>)+$/', '', get_sub_field('field_name')); ?>
This may not be the perfect solution for you. Also check out str_replace
and strip_tags
.
@debharrison, I believe this is more of a slider specific question than an ACF question.
Elliot has an example listed here for using flexslider: http://www.advancedcustomfields.com/resources/field-types/gallery/#wpshdo_3
http://flexslider.woothemes.com/
If the ACF is functioning and all you need is that click feature, I’d suggest looking into you sliders API for that feature or creating one.
Hope that helps!
Hey Elliot,
I’ve referenced this article quite a few times. This method has been very helpful but a case came up that this didn’t apply. I wanted to share my solution.
Issue:
Outputting the row ID can be problematic when using flexible content fields because a repeater can appear multiple times on the page, resulting in matching row IDs.
Solution:
Use PHPs built in random number generator to create a variable.
Here’s a basic example for use in any project:
<?php
// generate random var for IDs, anchors, etc.
$num = mt_rand ();
$num_var = sprintf ($num);
// echo random var
echo $num_var;
Here’s an example within a repeater field:
<?php if( have_rows('repeater_field') ): ?>
<?php while ( have_rows('repeater_field') ) : the_row(); ?>
<?php
// create random var id for backstretch
$num = mt_rand ();
$num_var = sprintf ($num); ?>
<?php echo $num_var; ?>
<?php endwhile; ?>
<?php endif; ?>
The number range can be altered for info here: http://www.php.net//manual/en/function.mt-rand.php
Hope that helps someone!
UPDATE
I’ve found a few instances where my solutions above didn’t work. When special characters AND similar titles are involved there comes a time to get super specific.
Here’s the combined solution that I’ve come up with from the research I’ve done.
It strips out tags, shortens the output so long title URLs aren’t a problem, and add a row ID for similarly titled links.
// Strip HTML Tags
$anchor_var = strip_tags(get_sub_field('section_title'));
// Clean up things like &
$anchor_var = html_entity_decode($anchor_var);
// Strip out any url-encoded stuff
$anchor_var = urldecode($anchor_var);
// Replace non-AlNum characters with space
$anchor_var = preg_replace('/[^A-Za-z0-9]/', '', $anchor_var);
// Replace Multiple spaces with single space
$anchor_var = preg_replace('/ +/', ' ', $anchor_var);
// Trim the string of leading/trailing space
$anchor_var = trim($anchor_var);
// Trim length of output
$anchor_var_trim = substr($anchor_var,0,15);
Here’s an example within a repeater field:
<?php if( have_rows('repeater_field') ): $i = 0; ?>
<?php while ( have_rows('repeater_field') ) : the_row(); $i++; ?>
<?php echo $anchor_var_trim; ?>-<?php echo $i; ?>
<?php endwhile; ?>
<?php endif; ?>
@neverything, thanks for your post. I used your example to make something for a project I’m working on, but all I needed to do was count number of field and apply different conditions. Here is my stripped down example below:
<?php
// get the count on the repeater field
// mabye use get_sub_field() instead of get_field() if it's nested
$count = count( get_sub_field( 'the_field' ) );
// begin $count conditions
if ( $count > 1 ) { ?>
// greater than 1
<?php the_field( 'great_than_1' ); ?>
<?php } else { ?>
// less than 1
<?php the_field( 'less_than_1' ); ?>
<?php } ?>
https://gist.github.com/emaildano/6b6c47ec2bc3be54fcc6
Elliot, never-mind!
That code works perfectly fine. Editing the custom fields I lost the post data and had to re-enter it.
That didn’t work but I just realized that I’m running WP v3.9 Alpha. I pulled it from git hub and didn’t notice the latest version update.
Rolling back to the latest 3.8.x release fixed the issue!
@elliot, not sure where to report this but that’s something worth checking out.
I found this previous post:
http://support.advancedcustomfields.com/forums/topic/wysiwyg-field-showing-as-textarea/
I’m going to give this a try and report back.
No errors, but I do think I narrowed down where the issue is coming from.
When I add a repeater field inside of a flexible content field, it breaks and will not save. Also, it reverts some of the custom settings such as the ‘add row’ title, etc..
Is there a bug report for nesting repeater fields inside of flexible content fields?
Great news! Thanks, Elliot.
Update
I found this thread: http://support.advancedcustomfields.com/forums/topic/field-group-not-accepting-more-than-69-fields/
But it hasn’t resolve my issue.
In case it helps I’ve attached my ACF XML export for review.
Elliot, Thanks!
This would be front end, inline JS so I can pull the custom fields for images.
I’m reading about the uniquid function and this looks like this will work. I’ll just need to setup a variable to use in both JS and PHP locations.
Thanks again.
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.