Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #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?

    #1440196

    PS: 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.

    #1440207

    Hi,

    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ünter

    #1440208

    Hi Günter, great, that was it! Now it works. :-)
    Thank you very much!

    #1440387

    Hi,
    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

Viewing 5 posts - 1 through 5 (of 5 total)
  • The topic ‘avf_magazine_header_content filter’ is closed to new replies.