最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

What is the right way to add PHP code to a certain part of a page

programmeradmin0浏览0评论

I know I can add PHP to the functions file. And I know I can make a plugin.

I basically need to make a calculator of sorts and send the values to an email signup.

What is the best way to achieve this. I think a plugin, but then how would I position the plugin at a place on an already existing page?

Sorry if this is a noob question, I really want to understand the correct way to achieve this before starting.

I know I can add PHP to the functions file. And I know I can make a plugin.

I basically need to make a calculator of sorts and send the values to an email signup.

What is the best way to achieve this. I think a plugin, but then how would I position the plugin at a place on an already existing page?

Sorry if this is a noob question, I really want to understand the correct way to achieve this before starting.

Share Improve this question asked Feb 5, 2021 at 18:53 EoinEoin 1156 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 1

A plugin is just a file that gets loaded into WordPress, it doesn't have a location on the page. In fact WordPress doesn't know which page it is yet when plugins are loaded. It may not even be a frontend page!

So if a plugin is just a place to put code such as hooks and filters, how do you embed code in a page?

There are several methods:

  • blocks
  • shortcodes
  • widgets
  • theme template files

You can register blocks/shortcodes/widgets in a plugin, whereas templates files are theme specific.

I recommend searching the site for how to create and use a shortcode, this will be the easiest option for you at the moment.

发布评论

评论列表(0)

  1. 暂无评论