-
AuthorPosts
-
April 17, 2024 at 12:50 pm #1440195
Hi, in Enfold 5.7 I’d like to add an ACF field value to magazine headers. In the file \wp-content\themes\enfold\config-templatebuilder\avia-shortcodes\magazine\magazine.php I found the following code line (1559):
$header_content = apply_filters( 'avf_magazine_header_content', $header_content, $entry );
That looks exactly like the right way for a header content modification. :-)
I added a respective filter in my child theme’s functions.php:add_filter('avf_magazine_header_content', 'avf_magazine_header_content_custom_query'); function avf_magazine_header_content_custom_query ( $header_content, $entry ) { $acf_field_value = get_field('plz', $entry->ID); if ($acf_field_value) { $header_content['plz'] = '<div class="acf-field-value">' . $acf_field_value . '</div>'; } return $header_content; }
But this throws an error saying just 1 parameter was passed but 2 are expected.
It seems that just $header_content is passed to my custom function. But I need the $entry parameter here as well, because without $entry->ID I cannot retrieve the ACF field value. In magazine.php there are 2 parameters passed.
Any clue why $entry is not received by my custom function?April 17, 2024 at 1:03 pm #1440196PS: I tried to modify magazine.php directly (that worked after all) and would like to put the modified file into my child theme directory to avoid it being overwritten on Enfold udates.
The original file path is: \wp-content\themes\enfold\config-templatebuilder\avia-shortcodes\magazine\magazine.php
I tried every possible subdir structure in the child theme folder, but to no avail. I placed the modified magazine.php in each of the following folders:- \wp-content\themes\enfold-child\config-templatebuilder\avia-shortcodes\magazine\magazine.php
- \wp-content\themes\enfold-child\avia-shortcodes\magazine\magazine.php
- \wp-content\themes\enfold-child\magazine\magazine.php
- \wp-content\themes\enfold-child\magazine.php
The file is not recognized there. Is it possible at all to put a modified shortcode file into the child theme folder?
Thanks.April 17, 2024 at 3:18 pm #1440207Hi,
You have to add all parameters to the add_filter function, otherwise it uses default parameters (where last one is 1):
add_filter('avf_magazine_header_content', 'avf_magazine_header_content_custom_query', 10, 2 );
Best regards,
GünterApril 17, 2024 at 3:30 pm #1440208Hi Günter, great, that was it! Now it works. :-)
Thank you very much!April 19, 2024 at 5:48 pm #1440387Hi,
Glad Günter could help, if you have any further questions please create a new thread and we will gladly try to help you. Thank you for using Enfold.Best regards,
Mike -
AuthorPosts
- The topic ‘avf_magazine_header_content filter’ is closed to new replies.