admin管理员组文章数量:1415119
I have this command that I'm using. I want it to use the template formating for the title but I can't figure out how to add it. I found this code online to strip everything and I added <?php wp_title(); ?>
which shows the title but in plain text. How can I add it to match the rest of the site? smdpphiladelphia
<?php
/**
* Template Name: Clean Page
* This template will only display the content you entered in the page editor
*/
?>
<!DOCTYPE html>
<html <?php language_attributes(); ?>>
<head>
<meta charset="<?php bloginfo( 'charset' ); ?>">
<meta name="viewport" content="width=device-width, initial-scale=1">
<?php wp_head(); ?>
</head>
<body>
<?php wp_title(); ?>
<?php
while ( have_posts() ) : the_post();
the_content();
endwhile;
?>
<?php wp_footer(); ?>
</body>
</html>
I have this command that I'm using. I want it to use the template formating for the title but I can't figure out how to add it. I found this code online to strip everything and I added <?php wp_title(); ?>
which shows the title but in plain text. How can I add it to match the rest of the site? smdpphiladelphia
<?php
/**
* Template Name: Clean Page
* This template will only display the content you entered in the page editor
*/
?>
<!DOCTYPE html>
<html <?php language_attributes(); ?>>
<head>
<meta charset="<?php bloginfo( 'charset' ); ?>">
<meta name="viewport" content="width=device-width, initial-scale=1">
<?php wp_head(); ?>
</head>
<body>
<?php wp_title(); ?>
<?php
while ( have_posts() ) : the_post();
the_content();
endwhile;
?>
<?php wp_footer(); ?>
</body>
</html>
Share
Improve this question
asked Aug 23, 2019 at 22:21
James E AndrewsJames E Andrews
1
2 Answers
Reset to default 0Basically, if I understand your question properly, you will want to look for another file named "header.php" (or "page-{something}-header.php" for a special header that only applies to a specific page type), which represents what is output by wp-head() (shown in your code).
If you open header.php, you should find something like the following:
<head>
<title> <?php wp_title(); ?></title>
...
Keep in mind, this can get really complex. There are many themes with several conditional statements to modify your page title for any of several different circumstances. See the following example of how complex a fairly simple theme can make it.
<?php
if (function_exists('is_tag') && is_tag()) {
echo 'Tag Archive for "'.$tag.'" - ';
} elseif (is_archive()) {
wp_title(''); echo ' Archive - ';
} elseif (is_search()) {
echo 'Search for "'.wp_specialchars($s).'" - ';
} elseif ( (!(is_404()) && (is_single()) || (is_page()) ) && !(is_front_page()) ) {
wp_title(''); echo ' | ';
} elseif (is_404()) {
echo 'Not Found - ';
}
bloginfo('name');
?>
</title>
If you already like your theme, but just want to customize how the page titles are drawn, you may want to review this brief tutorial for a better way to update page titles throughout your site, using add_filter('document_title_parts','your_customizing_function')
(documentation for document_title_parts).
I just figured out I could make it a lot easier by simpling adding teh custom attribute into the header code like so <h1 class="resurrect-entry-title resurrect-main-title">
本文标签: wp titleAssistance with wptitle function
版权声明:本文标题:wp title - Assistance with wp_title function 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745220521a2648374.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论