Where do I put this php code?
-
Hi,
I’m using the following code on my index page
<div id="content">
<?php
if ($posts) : foreach ($posts as $post) : start_wp();
// Faking multiple templates
if ($single) {
require('includes/single.php');
} else if ($cat) {
require('includes/category.php');
} else if ($s) {
require('includes/search.php');
} else {
require('includes/main.php');
}
endforeach; else:
require('includes/nomatches.php');
endif;
?>
</div>
It works great, but now I want to add the category title at the top of the list created when selecting a category from my menu and also add some text above the search results.
If I add this
<?php single_cat_title('); ?>
directly above this line
require('includes/category.php');
I get an error. If I include it in thecategory.php
file it gets repeated every line.
The same thing is happening for the search results.
Would somebody be kind enough to show me what i’m doing wrong and where I need to put the code?
TIA
Phillip
- The topic ‘Where do I put this php code?’ is closed to new replies.