-
AuthorPosts
-
January 6, 2020 at 11:16 am #1170658
Hello,
Is there a way I can add ACF fields in a portfolio grid/masonry without using the shortcode map and change one of the themefiles?
I want to use code I can put directly in my functions.php.Best regards,
JanineJanuary 7, 2020 at 1:24 am #1170871Hey Janine.94,
Thank you for the inquiry.
There are available filters added in the shortcode template that can be used to insert additional content in the portfolio grid or the masonry element. One example is the avf_portfolio_extra filter, which outputs extra content after the main article container, above the grid content.
Usage example:
add_filter('avf_portfolio_extra', function($output, $entry) { $output = '<span>Additional content</span>'; $output .= '<span>More content</span>'; return $output; }, 10, 2);
Best regards,
IsmaelJanuary 7, 2020 at 11:01 am #1170991Hi,
I am a colleague of Janine.
Right now we are using the following function:add_filter('avf_masonry_loop_prepare','avia_change_default_link', 10, 2); function avia_change_default_link($loop, $entries) { foreach($entries->posts as $key => $entry) { if($entry->post_type == "portfolio") { $opties = get_field('opties', $loop['ID']); foreach( $opties as $optie ) { $waarde .= "<li>".$optie."</li>"; } $more = "<div class='beschrijf' itemprop='text'><ul>".$waarde."</ul></div><div class='masonry-more-link-arrow vdwerfknopgrid'><span>ONTDEK</span></div>"; $loop['content'] = avia_backend_truncate($entry->post_content, apply_filters( 'avf_masonry_excerpt_length' , 60) , apply_filters( 'avf_masonry_excerpt_delimiter' , " "), "…", true, '') . $more; } } return $loop; }
It shows the selected checkboxes from the ACF fields correct but it keeps looping.
See the page in the private content (last machine).
It shows Tracks, Vario, Laag verbruik.
After this 3 it needs to stop but it is repeating the selected checkboxes.January 9, 2020 at 6:08 am #1171690Hi,
Thank you for the update.
We modified the code a bit. Please try this one.
function avia_change_default_link($loop, $entries) { $opties = get_field('opties', $loop['ID']); if($opties) { foreach( $opties as $optie ) { $waarde .= "<li>".$optie."</li>"; } $more = "<div class='beschrijf' itemprop='text'><ul>".$waarde."</ul></div><div class='masonry-more-link-arrow vdwerfknopgrid'><span>ONTDEK</span></div>"; $loop['content'] = avia_backend_truncate($entry->post_content, apply_filters( 'avf_masonry_excerpt_length' , 60) , apply_filters( 'avf_masonry_excerpt_delimiter' , " "), "…", true, '') . $more; } return $loop; } add_filter('avf_masonry_loop_prepare','avia_change_default_link', 10, 2);
Best regards,
Ismael -
AuthorPosts
- You must be logged in to reply to this topic.