-
AuthorPosts
-
March 30, 2020 at 3:50 pm #1199093
Hello, I’m trying to add an acf custom field inside the “taxonomy-portfolio_entries.php” loop.
I know how to do it for masonry by using the following function :add_filter( 'avf_masonry_loop_prepare', 'avf_masonry_loop_prepare_mod_cat', 10, 2 ); function avf_masonry_loop_prepare_mod_cat( $key, $entries ) { $clients = get_field('nom_du_client', $key['ID']); $key['text_after'] .= "<div class='client-name'>". $clients ."</div>"; return $key; }
But I’m not sure how to apply it to the avia_post_grid…
Alternatively, would it be possible to use the masonry layout instead of the grid layout on the portfolio category pages ?
Thanks a lot for your help!April 10, 2020 at 4:47 am #1202551Hey maxgorelkine,
Thank you for the inquiry.
You can manually edit the enfold\config-templatebuilder\avia-shortcodes\portfolio\portfolio.php file and add the extra content there, or use the avf_portfolio_extra filter, which is the same as the avf_masonry_loop_prepare filter but for portfolio element.
Best regards,
IsmaelApril 10, 2020 at 5:32 pm #1202696Hello Ismael, thank you! I will give it a try and let you know…
April 10, 2020 at 5:58 pm #1202701Hello, I tried to replace my code by
add_filter( 'avf_portfolio_extra', 'avf_portfolio_extra_mod_cat', 10, 2 ); function avf_portfolio_extra_mod_cat( $key, $entries ) { $clients = get_field('nom_du_client', $key['ID']); $key['text_after'] .= "<div class='zebra-client'>". $clients ."</div>"; return $key; }
But it doesn’t seem to work…
I’m trying to show the extra field in the grid used on portfolio category pages…- This reply was modified 4 years, 7 months ago by maxgorelkine.
April 14, 2020 at 4:25 am #1203428Hi,
Thank you for the update.
The filter should return an html output. Please try this code instead.
add_filter( 'avf_portfolio_extra', 'avf_portfolio_extra_mod_cat', 10, 2 ); function avf_portfolio_extra_mod_cat( $output, $entry ) { $clients = get_field('nom_du_client', $entry->ID); $output .= "<div class='zebra-client'>". $clients ."</div>"; return $output; }
Best regards,
IsmaelApril 14, 2020 at 10:16 am #1203504Thank you very much, it seems to be working! The only problem is that it displays the custom field above the thumb…
How ca I display it under the title instead ?
Thanks again!!- This reply was modified 4 years, 7 months ago by maxgorelkine.
April 16, 2020 at 2:23 pm #1204435Hi,
Replace the filter with avf_portfolio_title to render the additional content below the title.
add_filter( 'avf_portfolio_title', 'avf_portfolio_extra_mod_cat', 10, 2 ); function avf_portfolio_extra_mod_cat( $output, $entry ) { $clients = get_field('nom_du_client', $entry->ID); $output .= "<div class='zebra-client'>". $clients ."</div>"; return $output; }
Best regards,
Ismael -
AuthorPosts
- You must be logged in to reply to this topic.