我正在使用Divi,需要通过Divi挂钩,通过函数中的代码添加内容。我的孩子主题中的php。我正在测试基础知识,这段代码将事情放在主要内容之前:
function bgt_add_conditional_code_to_event_pages () {
echo do_shortcode(\'[et_pb_section _builder_version="4.9.3" _module_preset="default"][et_pb_row _builder_version="4.9.3" _module_preset="default"][et_pb_column _builder_version="4.9.3" _module_preset="default" type="4_4"][et_pb_text _builder_version="4.9.3" _module_preset="default"]\');
echo "<h1>This is a test</h1>";
echo do_shortcode(\'[/et_pb_text][/et_pb_column][/et_pb_row][/et_pb_section]\');
}
add_action( \'et_before_main_content\', \'bgt_add_conditional_code_to_event_pages\' );
但是!我希望它显示在主要内容之后。然而,当我改为“et\\u after\\u main\\u content”时。。。没有什么
我无法想象我做错了什么!希望有人能提出建议。
SO网友:Kenny Hall
我希望你做得很好!我想知道为过滤器添加优先级是否可以解决此问题。在过去,由于默认优先级太高或太低,我没有启动过滤器。你能试试这样的吗:
add_action( \'et_after_main_content\', \'bgt_add_conditional_code_to_event_pages\', 9999 );
看看这能不能解决问题?根据我在divi文档中所读到的内容,我认为您的工作方式应该是可行的。