WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] 2010 Child Themes and file Includes (4 posts)

  1. Digital Raindrops
    Member
    Posted 4 years ago #

    I am working on a 2010 Magazine theme, I use a lot of include files, I started to go down the route of using a child theme but gave up.

    I was getting an eror message when using the file include() with the path get_bloginfo() stylesheet directory, I cannot use TEMPLTEPATH as the path would look in the TwentyTen folder.

    I did google the error message and the answer is to edit the php ini, but that is not possible on shared hosting, is there a way around this, including a file from the child folder without using a url?

    I have worked it with a copy of 2010 and edited the theme, but I really wanted to use a child theme as it sems a better solution.

    David

    Here is the Magazine Theme still a work in progress

  2. Digital Raindrops
    Member
    Posted 4 years ago #

    I thought I had this fixed with:
    locate_template( array( '/includes/my-custom-file-1.php' ), true );

    This worked but when I added a second call:
    locate_template( array( '/includes/my-custom-file-1.php' ), true );
    locate_template( array( '/includes/my-custom-file-2.php' ), true );

    Only the first file loaded as WordPress could not find a function from file 2? :-(

    Anyone have an answer?

    David

  3. Digital Raindrops
    Member
    Posted 4 years ago #

    I found the answer in a child theme, just incase anyone else is starting with child themes.

    Lets say you have a modified parent theme and some Include file in the parent themes sub folders and some in the child theme.

    Parent Paths use:
    $fileurl = bloginfo( 'template_directory' ) .'/includes/my-file.php';
    $filepath = TEMPLATEPATH .'/includes/my-file.php';

    Child Theme Paths use:
    $fileurl = bloginfo( 'stylesheet_directory' ) .'/includes/my-file.php';
    $filepath = STYLESHEETPATH .'/includes/my-file.php';

    David :-)

  4. alchymyth
    Forum Moderator
    Posted 4 years ago #

    maybe of interest - just found this:

    http://codex.wordpress.org/Function_Reference/locate_template

    untested, it might work like this:
    <?php locate_template(array('/includes/my-file.php'),true); ?>

Topic Closed

This topic has been closed to new replies.

About this Topic