• 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 the category.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

Viewing 6 replies - 1 through 6 (of 6 total)
  • Phillip,
    Can you show me how you want it to appear on your page? If I can see what your desired output is, I’ll have an easier time helping you :^)

    Thread Starter planetphillip

    (@planetphillip)

    At this exact moment I can’t because my server is down ?? But I will set up an example as soon as my host gets things back up again.

    Can you do a quick sample here?

    Thread Starter planetphillip

    (@planetphillip)

    The output from the cat code would be a simple list of post titles that are links.
    Post title 1
    Post title 2
    Post title 3
    Post title 4
    Post title 5

    What I would like is just the name of the categoryt title above the list. I will worry about the format later. SOmething like:
    Category Name
    Post title 1
    Post title 2
    Post title 3
    Post title 4
    Post title 5

    I hope that helps!

    Thread Starter planetphillip

    (@planetphillip)

    OK,
    This is a very temp and very bad idea of what it should look like.
    https://www.planetphillip.com/1.php
    This is just a static page to show you where I want the category title to be, obvioulsy I will format it with CSS.
    TIA

    I found a plugin that someone created that does what your looking for. I haven’t tested it, but the creator may be able to help you.
    https://mookitty.co.uk/devblog/category/show-categories/

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Where do I put this php code?’ is closed to new replies.