We are transitioning over to a new forum platform. Please post new issues there. Existing threads will be dealt with here unless you choose to move them over. Visit the new forum

Forum

Thread tagged as: Question

Dynamic title field in head

Hi, I want to make my post.php title field dynamic and get it from postTitle.

<title><?php echo $title; ?></title>

I am running default variables before the <html> and change those witch are different. In this case I want to call postTitle.

<?php include('include/default-vars.html'); // Different variables go below

    if (perch_get('s')) {
        $title = perch_blog_custom(array(
            'template' => 'slug2.html',
            'filter' => 'postSlug',
            'match' => 'eq',
            'value' => perch_get('s') ));
    }

    echo $title; 
?>

Echo is working but is not setting the variable... any idea?

Raul Serrano

Raul Serrano 0 points

  • 4 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

You need to return the value:

$title = perch_blog_custom(array(
            'template' => 'slug2.html',
            'filter' => 'postSlug',
            'match' => 'eq',
            'value' => perch_get('s') 
     ), true);

Thanks!