Solved

Include HTML in Wordpress SideBar.php

Posted on 2011-03-22
6
353 Views
Last Modified: 2013-12-13
I want to include some HTML within the sidebar.php and I get the error below.

My code in sidebar.php:
<?php include 'mypage.html'; ?>


Error msg:
PHP Warning:  include() [<a href='function.include'>function.include</a>]: URL file-access is disabled in the server configuration in D:\Sites\mysite.co.uk\public_html\blog\wp-content\themes\sduk\sidebar.php on line 81
PHP Warning:  include(http://www.mysite.co.uk/includes/mypage.html) [<a href='function.include'>function.include</a>]: failed to open stream: no suitable wrapper could be found in D:\Sites\mysite.co.uk\public_html\blog\wp-content\themes\sduk\sidebar.php on line 81
PHP Warning:  include() [<a href='function.include'>function.include</a>]: Failed opening 'http://www.mysite.co.uk/includes/mypage.html' for inclusion (include_path='.;C:\php\pear') in D:\Sites\mysite.co.uk\public_html\blog\wp-content\themes\sduk\sidebar.php on line 81

Can someone help?

I don't want to change it to .php as I want to use the same include in an .ASP page.

Thanks.
0
Comment
Question by:benners70
  • 3
  • 2
6 Comments
 
LVL 2

Expert Comment

by:stopReplying
ID: 35188916
Try renaming your page from mypage.html to mypage.php and include it.
0
 
LVL 2

Expert Comment

by:stopReplying
ID: 35188930
Also, mypage.html must be in the same folder as sidebar.php (sorry for the post above, failed to read the question entirely)
0
 

Author Comment

by:benners70
ID: 35189373
It does seem to work if I put the file in the same folder. I should have been more accurate with my question. The code I was using was:

<?php include 'http://www.mydomain.com/inc/mypage.html'; ?>

and this gave the error. If I put the file in the same folder as sidebar.php and use the following it works.

<?php include 'mypage.html'; ?>

I'd rather not have it in the same folder. Is there a way I can use the exact URL?
0
 
LVL 2

Accepted Solution

by:
stopReplying earned 125 total points
ID: 35189528
For example, if sidebar.php is in root folder and mypage.html is in inc folder, include inc/mypage.html

If you need to go up one level (for example if you have sidebar.php in root/folser/sidebar.php and mypage is in root/inc/mypage.html) include '../inc/mypage.html'
../ is equal to 'up' button in windows explorer.
0
 

Author Comment

by:benners70
ID: 35189735
Thank you, I have it working now with.

<?php include '../includes/mypage.html'; ?>
0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
So you have coded your own WordPress plugin and now you want to allow users to upload images to a folder in the plugin folder rather than the default media location? Follow along and this article will show you how to do just that!
The purpose of this video is to demonstrate how to Test the speed of a WordPress Website. Site Speed is an important metric of a site’s health. Slow site speed can result in viewers leaving your site quickly and not seeing your content. This…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question