1

Okay so here is my head

<head>

<meta charset="utf-8">
<title><?php echo $title ?></title>
<meta name="description" content="<?php echo $metadescription ?>">
<meta name="author" content="Talk About Film">

</head>

and my pages

<?php 
$title ="Talk About Film | Trailers | <?php echo the_field('trailer_title'); ?>";
$metadescription= "Watch the latest trailer for <?php echo the_field('trailer_title'); ?>, watch the latest trailers at Talk About Film";
include 'includes/header.php' ?>

In the source however the PHP tags show not the content it pulls from the field. i.e

 <title>Talk About Film | Trailers | <?php the_field('trailer_title'); ?></title>

Not sure if you can use PHP in this way, or if there is a simple fix?

3
  • Try $title ="Talk About Film | Trailers | " . the_field('trailer_title') Commented Feb 28, 2014 at 18:09
  • You have <?php ?> tag into other <?php ?> tag.It is not correct.Fix it. Commented Feb 28, 2014 at 18:09
  • 1
    You can't embed php within php like that. $meta = "Foo" . get_the_field(..) is what you need. Commented Feb 28, 2014 at 18:28

2 Answers 2

1
<?php 
$title ="Talk About Film | Trailers | <?php echo the_field('trailer_title'); ?>";
$metadescription= "Watch the latest trailer for <?php echo the_field('trailer_title'); ?>, watch the latest trailers at Talk About Film";
include 'includes/header.php' ?>

should be

<?php 
$title ="Talk About Film | Trailers | " . the_field('trailer_title');
$metadescription= "Watch the latest trailer for " . the_field('trailer_title') . ", watch the latest trailers at Talk About Film";
include 'includes/header.php' ?>
Sign up to request clarification or add additional context in comments.

Comments

1

You're already inside a <?php ?> block when you open another. Change it to this:

<?php 
$title ="Talk About Film | Trailers | ".the_field('trailer_title');
$metadescription= "Watch the latest trailer for ".the_field('trailer_title').", watch the latest trailers at Talk About Film";
include 'includes/header.php' ?>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.