Ioana Pristoleanu Ioana Pristoleanu - 4 months ago 8
PHP Question

Wordpress - Include php file with name of category?

I'm trying to include a php file which contains description for each of my categories. So when I'm in category Cat1, I want to see the description of Cat1, when I'm in Cat2, the description for Cat2 and so on.

I tried the following code:

include (single_cat_title() . '.php');

But it just displays the title of the category. When I tried this:

$name = "Cat1";
include ($name . '.php');

it works, but if i add single_cat_title() instead of the hard coded "Cat1" it stops working.

Thank you!


try this:

<?php include (single_cat_title('',false) . '.php'); ?>

Referenced from: