0

hi, I am aware there are far easier and simpler ways to solve this problem, but due to certain circumstances, I am unable for instance to change filetypes etc..

so, here we go:

using wordpress with the thesis theme, I need to append an html file(shop.html) onto a page(gardens).

my original solution was to use a DOM parser to get the html into a php file(test.php), which I then include()d onto the page, replacing the page content with my own code:

<?php include( TEMPLATEPATH.'test.php');

now however, I need to add the html file at the end of a page with other text on it. I thought that a shortcode solution would do the trick. what I did was:

function ce_snowdrop_shop(){
	return include( TEMPLATEPATH . 'test.php' );
}
add_shortcode('snowdrop-shop', 'snowdrop_shop');

in the post I added [snowdrop-shop] at the end, and it worked - the code all showed up, but in the wrong place.

the shop.html code appeared ahead of the post and where the shortcode was, '1' appeared.

I then tried:

function ce_snowdrop_shop(){
	$shop = file_get_contents( TEMPLATEPATH . 'test.php' );
	return $shop;
}

that sorted out the layout, but instead of shop.html code, it just returned the dom parser code from test.php

so my question is:
if shop.html has to stay an html file, how can I append it to the end of a wordpress page?

also, is there a way of executing test.php before saving it into a string so that it will give the code from shop.html?

i realise this may seem rather complicated, and could be solved easily if shop.html was changed into shop.php.. but unfortunately, I can't do that. so please help me out. Thanks!

2
Contributors
2
Replies
3
Views
6 Years
Discussion Span
Last Post by k9shark
0

turns out I made it too complicated!

I've sorted it now - I put the code in test.php as a function under functions.php that reads the html file, and returns a string containing the html code.

now wherever i need it I just echo the function from above.

as for getting it into the post, I created a wordpress shortcode that echos the function.

thanks anyway ardav though!
I think I just needed to take a step back and think it all through again hehe.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.