Is there any way to override a WordPress template with a plugin?

前端 未结 2 1676
陌清茗
陌清茗 2020-12-16 18:43

I\'d like to make a landing page. If plugin detects some GET or POST requests it should override wordpress theme and show its own.

It would work somehow like that:

2条回答
  •  無奈伤痛
    2020-12-16 19:13

    You need the hook template_include. It doesn't seem documented in the Codex, but you can find more examples here in SO or in WordPress StackExchange

    Plugin file

    Custom Template in Plugin folder

    Result

    Visiting any url of the site with ?mod=yes will render the plugin template file, e.g.: http://example.com/hello-world/?mod=yes.

提交回复
热议问题