I'm using a set of query vars and rewrite rules to load a new page. My final call to the page looks like this:
add_filter( 'template_include', 'se343855_template_include', 50 );
function se343855_template_include( $template )
{
$sign1 = get_query_var('sign1', false);
$sign2 = get_query_var('sign2', false);
if ( $sign1 !== false || $sign2 !== false ) {
// if this code is located in plugin file
$template = plugin_dir_path(__FILE__) . '/pages/form.php';
}
return $template;
}
This works, and the form.php page looks similar to this:
<?php include_once(dirname( __FILE__ ).'/../shortcodes/functions.php'); ?>
<?php get_header(); ?>
<div id="primary" class="content-area grid-parent mobile-grid-100 grid-75 tablet-grid-75">
<main id="main" class="site-main">
<div>Page</div>
</main>
</div>
<?php get_sidebar(); ?>
<?php get_footer(); ?>
I need to set the page title (i.e., the content between the <title></title>) and a few meta tags (description, author, etc.) from within the form.php page.
I've seen a few methods for changing the title, namely by filtering on 'pre_get_document_title', but I don't want the title to change on every page. I haven't found any consistent way to update/add meta tags.
Any help on this is greatly appreciated!
pre_get_document_title
filter hook orwp_head
action hook you can use conditional tags or check query vars (as in the above code) to change title / add meta tags only on one selected page.