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

template include - Should I use do_action in the header file?

programmeradmin1浏览0评论

I have a lot to add on the header file because of if/else condition. And it makes the file very messy. So, I have decided to include another file...

So how to add it:

  1. Creating a function file and add it with do_action()
  2. Getting a template file get_template_part()

I have a lot to add on the header file because of if/else condition. And it makes the file very messy. So, I have decided to include another file...

So how to add it:

  1. Creating a function file and add it with do_action()
  2. Getting a template file get_template_part()
Share Improve this question asked Jan 8, 2020 at 7:27 webfuelcodewebfuelcode 212 bronze badges 2
  • In which part of header.php? inside <body>? And what exactly do you want to put in there? – Krzysiek Dróżdż Commented Jan 8, 2020 at 8:24
  • Yes, inside body. For logo and social icons when it is set(custom image) the header with logo will appear differently from not define the custom header image. – webfuelcode Commented Jan 8, 2020 at 10:48
Add a comment  | 

1 Answer 1

Reset to default 0

In my development experience.
get_template_part() is better way to maintain In the future.

https://developer.wordpress/reference/functions/get_template_part/

发布评论

评论列表(0)

  1. 暂无评论