I don’t think its possible to fix, it seems to be a limitation with custom fields and the_content sadly.
Hi @acf-support
I foolishly work on my live website, haven’t figured out how to use MAMP for a local environment. What you’re seeing now is the function with this removed:
$content .= get_sub_field(‘sub_field_3’);
with only the first $content line, it seems to work okay.
I’m now trying to research ways to implement this type of function within the single-listing.php (the custom post template).
That way, I can both create a layout for these posts and also have the content situated within the the_content(), though it seems very difficult to achieve…
Hi @james
I see, maybe we can ignore my mentioning of the plugin. I want to include all of my fields for a layout to be included in the the custom post the_content()
I tried this, which works and lets my ACF fields work with other plugins, but it repeats hundreds of times. Why is that? Here it is live http://jeremynative.com/onthissite/listing/sugar-loaf-hill/
function add_acf_content( $content ) {
if( have_rows('repeater_field_name') ) {
while( have_rows('repeater_field_name') ): the_row();
$content .= "<h2>" . get_sub_field('title_sub_field') . "</h2>";
$content .= get_sub_field('sub_field_3');
endwhile;
}
return $content;
}
This might only work in photoswipe. What the plugin usually does is find images in your the_content(), and adds ‘data-size’ to them as a href value to make sure the plugin knows that should be a lightbox image.
What I did was put this into my functions.php:
function filter_image_send_to_editor($html, $id, $caption, $title, $align, $url, $size, $alt) {
$html = sprintf('<a class="fancybox-img" href="%1$s"><img alt="%2$s" src="%1$s" data-size="2080x890" /></a>', esc_attr(esc_url($url)), esc_attr($title));
return $html;
}
add_filter('image_send_to_editor', 'filter_image_send_to_editor', 10, 8);
I pulled it from another thread, but it works. Now just have to figure out how to get data-size to be a dynamic value instead of static, but that isn’t related to ACF anymore
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.