• mmtomm

    (@mmtomm)


    Hallo,

    I really mess arround hours now with finding the right path to use file_get_contents
    The Idea was to create a workarround for a include which is not possible in WP with PHP. So I wrote following function in functions.php to add a Shortcode

    function laden_offen_snippet() {
    	$laden_offen = file_get_contents(dirname(__FILE__) . './offen.php');
    	echo $laden_offen;
    }
    add_shortcode('offen', 'laden_offen_snippet');

    and I get this warning
    Warning: file_get_contents(/customer/xxxxx_xxx/web/wordpress/wp-content/themes/designpile./offen.php)
    [function.file-get-contents]: failed to open stream: No such file or directory in /customer/xxxxx_xxx/web/wordpress/wp-content/themes/designpile/functions.php on line 7

    Of course I get this wrong because it gives me back the full path, but I don’t know how to get the right one in there ??
    as I wrote this in the functions.php of the theme this is located here:
    /customer/xxxxx_xxx/web/wordpress/wp-content/themes/designpile/
    The file I want to include is is located at /web/wordpress/offen.php, meaning in such a way I would have included it from within an html file.

    I have searched arround and did experiments with abspath and other stuff and I’m still lost (cause I’m not an real coder ??

    may someone can assist me there, please?
    Thanks a lot
    Tom

Viewing 1 replies (of 1 total)
  • Thread Starter mmtomm

    (@mmtomm)

    Hi again,

    no ideas to do this better?
    In the meantime I#m using the full path
    /customer/xxxxx_xxx/web/wordpress/
    but I think this is not an good idea

    Thank you
    Tom

Viewing 1 replies (of 1 total)
  • The topic ‘finding the right path, using file_get_contents’ is closed to new replies.