Forum

Thread tagged as: Question

Page Title for Category name

How can I make the head 'page title' for a Category page show just the Category title?

My current method is to use:

'title' => 'Websitename - ' . perch_get('cat'), true, 

However this just returns the "Websitename - setname/categoryname"

I want it to only show "Websitename - Categoryname" (without the setname)

The URL for the page is:

hosting.co.uk/products/category.php?cat=setname/categoryname/
James Tedder

James Tedder 0 points

  • 4 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

You can get the category title with perch_category()

https://docs.grabaperch.com/functions/categories/perch-category/

I am not getting any luck with this. I have tried replicating how the Blog Post works with now luck. This returns nothing:

'title' => 'Company Name: ' . perch_category(perch_get('s'), 'catTitle', true),
Duncan Revell

Duncan Revell 78 points
Registered Developer

The second parameter of perch_category() needs to be an array (where you have 'catTitle')

You probably want to use skip-template, pick out catTitle from the resulting array and concatenate that to your string.

Sorry I don't really understand this :-(

Any chance for a Copy/Paste method for a simpleton?

Rachel Andrew

Rachel Andrew 394 points
Perch Support

As Duncan has explained, the second parameter needs to be an array.

perch_category(perch_get('s'), array());

The array contains any options you want to set, this is exactly the same as perch_content_custom and other functions in Perch and is just PHP.

I've written up some basic PHP information here: https://docs.grabaperch.com/perch/building/servers/how-do-i-get-started-with-php/