Reputation: 13
My goal is simple... I created a page in the WordPress root named download.php:
<?php
$heading_bs = 'My bla bla heading..';
require_once('wp-load.php');
get_header();
// My code here...
get_footer();
?>
How do I insert $heading_bs in <title>
and meta title
?
How can I make a custom description?
Upvotes: 0
Views: 2602
Reputation:
The typical approach would be to make download.php a template, since otherwise it would not get the required WordPress support for get_header() and get_footer().
The <title>
tag is created in your header.php template file. You can test in header.php for your special template and adjust accordingly:
<title><?php echo (get_page_template() == 'download.php') ? $heading_bs : wp_title() ?></title>
You could also test for the existence of the special heading variable:
<title><?php echo (isset($heading_bs) && $heading_bs) ? $heading_bs : wp_title() ?></title>
or if you would rather keep the standard title statement:
<?php if (isset($heading_bs) && $heading_bs) : ?>
<title><?php echo $heading_bs ?></title>
<?php else : ?>
<title>...your current title...</title>
<?php endif; ?>
Upvotes: 1