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

Add additional functions file instead of functions.php

programmeradmin1浏览0评论

I was wondering if i could have more than one functions file in wordpress and how do I call these actions in for example a registration form?

Thanks.

EDIT

This the process file im trying to post to that has the code that connects to db and adds new user to db. however this isnt working.do i need to include anything at the top of the page

I was wondering if i could have more than one functions file in wordpress and how do I call these actions in for example a registration form?

Thanks.

EDIT

This the process file im trying to post to that has the code that connects to db and adds new user to db. however this isnt working.do i need to include anything at the top of the page

Share Improve this question edited Jun 16, 2020 at 9:39 Louise Finch asked Jun 11, 2020 at 14:56 Louise FinchLouise Finch 211 silver badge3 bronze badges 1
  • The relative path here won't be relative to the template file when it gets included in something else, so that isn't going to work. You could switch that to be an absolute path to your registerProcess.php instead, but then you're calling a non-WP PHP file: it might be better to handle the post some other way. – Rup Commented Jun 16, 2020 at 10:03
Add a comment  | 

1 Answer 1

Reset to default 1

You can include multiple files in your functions.php. I do this to keep things organized. All my functions are in a functions subfolder, so my functions.php file just looks like this:

require get_template_directory() . '/functions/function-1.php';
require get_template_directory() . '/functions/function-2.php';
require get_template_directory() . '/functions/function-3.php';

If you have functions you only want called on certain pages, for example, you can do this:

if ( is_page( 'registration-form' ) ) :
    require get_template_directory() . '/functions/registration.php';
endif;
发布评论

评论列表(0)

  1. 暂无评论