Tag Info

New answers tagged

1

Please clarify where you initiate the object $user in both ways (function.php and header.php). This is another thread on stack with similar kind of issue, have a look: Organizing Code in your WordPress Theme's functions.php File? Thanks, Vee


0

Including a file inside a subdirectory is the same as any other as long as you know the path to the file. Since it's possible to move the 'wp-content' directory, don't pass that part of the path to the require statement; instead, use the WP_CONTENT_DIR constant. require_once WP_CONTENT_DIR . '/new-directory/my-file.php'; Also, you can leave out the ...


1

yes the title will work for a file. You can use get_template_part() function to inlude your file within a wordpress template file like single.php Function Reference/get template part


1

Your problem is that you've used the get_template_directory_uri() function for your include path. As indicated by the function name, this returns a URI (not a path), which is no use for including one php file into another. Simply enter the relative path of the file to be included. E.g. if your structure is: /my-theme |--functions.php |--/lib ...


0

In my opinion, your functions file can be as big as you want it, but organizing functions into includes is a very logical process. I would first check that get_template_directory_uri() is returning the correct path. You can also include files without the full path within your theme if /admin/ is in your theme root: ...


2

I always break my functions.php up into more managable, specific functionality files, for instance, all footer related functions goes into a file called footer-functions.php and pagination functions goes into a file called pagination-functions.php. This way, my code stays organised, managable and I don't kill my functions.php. This however, is only related ...



Top 50 recent answers are included