Use Theme Hooks from functions.php

edited February 22 in Other

Hi,

I would like to address the Theme Hook "mfn_hook_content_before" to display a custom content with PHP based on the WPML language.

I'm not very experienced developer, but I tried this in my child theme functions.php:


global $custom_content;

function mfn_hook_content_before( $content ) {

  $custom_content = 'Hello WordPress';

if (ICL_LANGUAGE_CODE == 'es') $custom_content = "Hola WordPress";

  $custom_content .= $content;

  return $custom_content;

}

add_filter( 'the_content', 'mfn_hook_content_before' );


The result prints in the content area, and not earlier in the mfn_hook_content_before area :/

Could you please tell me how to right address the Hook with PHP?

Thanks in advance,

Miguel

Please sign in to unlock conversation.

If you don't have an account yet, please register now