Support » Fixing WordPress » How do I call a file from the text widget?

  • Hi, I try to keep this short. I have html code in the text area of a text widget. Its code for a table that is working fine but it is getting to large to maintain in the text box. Modifying the file outside of the box and then cutting and pasting into it has worked fine, but it would be nice if I could just use code to call the file “within” the text box widget itself. I have placed the table code in a file called: footercode.html, and I have used the following code in the text widget box:


    and placed the footercode.html file in the theme directory, but of course it doesn’t work, else I wouldn’t be here. If someone could let me know what I am doing wrong i’d appreciate it. Thanks.

Viewing 5 replies - 1 through 5 (of 5 total)
  • You can use HTML in the Text Widget, but just like pages and posts, not PHP.

    The Text Widget can hold a variety of HTML, XHTML, and multimedia links and players such as video and object embeds.

    You could likely iframe it.



    Forum Moderator

    use a plugin to get a php enabled text widget;
    for instance:

    Unless I’m misunderstanding something, you have the option at the bottom of the text widget to handle PHP as it clearly says:

    Execute code within <?php ?> tags

    I have this box checked. When I use the code as mentioned in my initial post it recognizes it, but I get the following error:

    Warning: fopen(footercode.html) [function.fopen]: failed to open stream: No such file or directory in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\www\wordpress\wp-content\themes\mystique\atom-widgets.php(4774) : eval()'d code on line 2

    I’m guessing the PHP code I’m using in the text box has an error on line 2, being:


    perhaps the syntax is wrong, as I got this online somewhere.

    Execute code within <?php ?> tags

    That is from a plugin or theme, not default WordPress.

    That is from a plugin or theme, not default WordPress.

    Yes, that is true, however I have executed PHP from within the themes text box before without trouble. Apparently, it is something I’m doing wrong, either with the code or placement of the file, or….

    Back to my initial concern though, I don’t have to use the code I’m using. Anything that works, whether it is PHP or something else would be great. I just want something that will “go get a file” when called from a text box. Thanks

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘How do I call a file from the text widget?’ is closed to new replies.