Does your code give you the right string? It isn’t mangled? If it is a good string, you might be able to use eval to include the file.
If you don’t mind my asking, why do you need to include this via a custom field instead of writing it into single.php, perhaps wrapped in a switch?
Thread Starter
Martin
(@mcundric)
If I typed in the box value just normal text, then the text is displayed correctly at the desired location.
If I include php code, then I see nothing.
Hmm … How do I use eval? I am a beginner in php.
Custom fields: I want to use it because I do not want to use the post template files as templet_single_home.php, template_single_products.php. In such a case I would have to create too many template files.
Thanx for your time!
But you could include a keyword in your custom field and a switch in a single template.
$values = get_post_custom_values('Page poster');
switch($values) {
case 'home' :
include(TEMPLATEPATH.'/home_include.php');
break;
case 'products' :
include(TEMPLATEPATH.'/products_include.php');
break;
}
Its going to be easier to write and easier to maintain. Besides, eval() is a dangerous thing. You have to be very careful with it.