I am trying to modify a theme on wordpress. The theme shows a slider on the front page, which reads from the featured.php file.
I have gone into the featured.php and removed all the PHP code. I can inject my custom HTML into the featured.php and the pages display properly, however I want the page to display from a wordpress page.
So i tried to:
<?php
$html = file_get_contents('http://www.mydomain.com/homepage-featured');
?>
The above link corresponds to a page i created in wordpress. So i want to be able to inject my HTML into that page and then when you load my homepage, the PHP tells the browser to display the contents of this URL.
The above code doesn’t work.
Thanks for the help.
file_get_contents()– as its name suggests – reads a file in but does not print it. You need toechoyour$htmlvariable. A better way is to userequire()orinclude()but if I were you I would put my custom file on the same server so that way you don’t have to use the file from a remote location thus sparing network traffic.