0

I've created a simple site specific functions plugin but I'm having some trouble including additional files to it.

Basically I'm trying to keep things separated so I've got one php file for general functions (The default plugin file) and another for custom post types and taxonomies.

Here's a sample of my current code, does anyone know where I'm going wrong?;

<?php
/*
Plugin Name: Functions Plugin
Description: Site specific functions
*/

include( plugin_dir_path( __FILE__ ) . 'types.php');

/* General Functions Here */

?>
6
  • Try without using plugin_dir_path() function like this include( 'types.php'); Commented Sep 5, 2013 at 14:29
  • Are you sure the file is named exactly types.php and it exists in the same folder of plugin file? How have you tested that the including is not working? Have you tried your plugin with only this code? If you replace include with require what happen?
    – gmazzap
    Commented Sep 5, 2013 at 14:31
  • I tried that to start with, I just got the white screen of death. Commented Sep 5, 2013 at 14:31
  • @G.M. Yes, I've tried all of those things. The file is 100% called types.php and is in the same folder Commented Sep 5, 2013 at 14:32
  • I can't be sure, but seems there is some fatal error in your 'types.php'
    – gmazzap
    Commented Sep 5, 2013 at 14:32

1 Answer 1

1

try this

include(plugins_url( 'types.php' , __FILE__ ));

or

$p_url=plugins_url();
$types_url=$url.'/your-plugin-name/types.php';
include($types_url);

Note: don't forgot about path if have that file in a sub folder like inc or js,assets. Mention them

1
  • 1
    plugins_url works? Are you testing on local environmnet, don't you? I bet this will not work on online server. allow_url_include is often disabled on webservers, and it should be so. @Poisontonomes
    – gmazzap
    Commented Sep 5, 2013 at 14:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.