在标题后显示WordPress插件


Display WordPress plugin after the header

我正在为WordPress开发一个插件。我的插件包含一个表单。我想在标题后的某些页面中显示此表单,但我无法实现这一点。

这就是我到现在为止显示表单的方式。它显示的形式在每个网站的顶部,这不是我想要的。

function pre_display_form() {
     include("form.php");
}
add_action("init", "pre_display_form");

我用add_actionadd_filter做实验,但没有成功。我找不到右勾拳。

我知道一定有办法。谁能帮我一下?

试一下,它应该为你工作:-

add_action('wp_head','wdm_form_include');
function wdm_form_include(  ) {
        //here you can assign page ids where you want to display form
        $page_ids = array(1,2,3);
        if(in_array(get_the_ID(),$page_ids)){
           //if current page id is in page ids array then including form
            include("form.php");
        }
}