- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
/"> > footer.php 看起来像这样-6ren">
问题是在我的单页导航网站上没有填充标题标签。
page.php
看起来像这样:
<?php
locate_template( 'page-home.php', true );
exit();
page-home.php
看起来像这样:
<?php get_header(); ?>
<?php get_template_part('template-sections/slider'); ?>
<?php get_template_part('template-sections/services'); ?>
<?php //etc. ?>
<?php get_footer();
header.php
看起来像这样:
<!doctype html>
<html <?php language_attributes(); ?>>
<head>
<meta charset="<?php bloginfo( 'charset' ); ?>"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<link rel="profile" href="http://gmpg.org/xfn/11"/>
<base href="<?php echo get_site_url(); ?>/">
<?php wp_head(); ?>
</head>
<body itemprop="hasPart" itemscope="" itemtype="http://schema.org/WebPage" <?php body_class(); ?>>
<!-- etc -->
footer.php
看起来像这样:
<?php wp_footer(); ?>
</main>
<aside class="aside">
<div class="aside__content">
</div>
</aside>
</div>
</body>
</html>
是的。后端有一个名为 home
的页面。我希望 Wordpress 选择该标题并将其用作 header.php
中的标题标签。
据我所知,Wordpress 通常会自动填充标题标签。那么这里的问题是什么?谢谢!
PS:我没有在我的自定义 Wordpress 主题中的任何地方使用 wp_title
过滤器。
最佳答案
好的,我找到的解决方案可能会对其他人有所帮助。所以我可以随意将它张贴在这里。
部分 1. 与标准比较 twentyseventeen
主题。我发现 Wordpress 需要 add_theme_support( 'title-tag' );
能够管理标题。 (否则我想你应该自己在 <title>
中添加一个 header.php
标签。
第 2 部分。我需要向 functions.php
添加一个自定义过滤器以所需格式显示标题。例如(使用 SEO 插件):
function custom_title( $title_parts ) {
$page_id = site_get_page_id(); // custom function, you might want to use global $post here
$seo_title = @get_post_meta( $page_id, '_aioseop_title' );
if ( isset( $seo_title[0] ) ) {
$title = $seo_title[0];
} elseif ( isset( $page_id ) ) {
$title = get_the_title( $page_id );
}
$page_title = isset( $title ) ? $title : 'Page not found in backend';
$title_parts['title'] = $page_title;
return $title_parts;
}
关于php - Wordpress wp_head() 标题标签不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53205142/
如何将脚本文件添加到 wp_head 的最顶部? 根据本指南,使用下面的代码将始终将我的新脚本文件添加到最底部: add_action('wp_head','hook_javascript'); fu
我已经编写了一个简单的插件供我自己使用,并且我正在尝试将一些 javascript 插入到 head 标记中。 如果我使用 add_action( 'init', 'add_to_head' ); 然
在 Wordpress 中,我有一个页面模板,它使用网站的其他部分不使用的特定 JS 文件和 CSS 文件。在这个特定的模板页面上,有没有办法在调用 wp_head 之前将这些项目添加到头部? 我意识
在wordpress主题中的header.php中,有一个wp_head()函数,表面上看不出什么玄机,只能在浏览器中查看源代码才能看出它所生成的如下代码: 复制代码 代码
我下载的许多插件都使用 wp_head 操作 Hook 将 JavaScript 添加到header,我一直使用 wp_enqueue_script() 在标签内输入 JS/Ajax。有什么不同?这是
问题是在我的单页导航网站上没有填充标题标签。 page.php 看起来像这样: > "/> /"> > footer.php 看起来像这样
我正在做一些 SEO 页面加载工作,Google 建议的其中一件事是将 asyng 添加到脚本标记中,以便它们更快地加载页面。 建议如下: https://developers.google.com/
大家好,我来这里已经有一段时间了,但刚刚决定加入。 我是 php 的新手,我正在尝试使用 WordPress 作为 CMS 创建一个网站。 无论如何,我基本上是在制作我自己的主题,因为我不希望我的网站
当直接移到顶部后与其他两个 jQuery 脚本发生冲突 section 并且这只发生在“产品”页面中。 conflicts with jQzoom.js and Navigation/jquer
我已将这段代码添加到 functions.php,但 startwordpress_scripts() 函数没有运行。 function startwordpress_scripts() {
我的问题是,当我在 header.php 中注释掉 wp_head 时,CSS 看起来很好。但我目前正在为该网站使用插件(Mailpoet、Formidable)。当 wp_head 被注释掉时,上述
这里是第一个问题。我想知道你们是否可以帮助我。 所以我试图将一个静态的 Bootstrap 主题网站传递到一个动态的 CMS wordpress 网站。所以我用 html/css 对网站进行编码,将其
我正在使用简单的 ajax 方法在 wordpress 站点中加载内容:我捕捉到对导航链接的点击并将 GET 参数添加到 url: jQuery('#topnav a').click(function
我正在编辑最新 wordpress 附带的标准二十三主题。 我需要将一些我自己的 .css 文件添加到 wp_head 中,但我不确定如何执行此操作。我目前在 wp_head 之外调用我的文件,但这很
我有这个 JavaScript 代码,我使用 wp_enqueue_script() 函数将其包含在我的插件中。一些 fork 告诉我,我需要添加 wp_head() 才能使其工作......那么我可
大家好,我在使用 Wordpress 网站时遇到了一些问题。 我正在改变脚本在网站上的加载方式(异步与同步)并清除无用的脚本(多个版本的 jquery 等)。其中一些在标题 (header.php)
遇到一个让我发疯的问题,原因是它应该是一个非常简单的修复,基本上在我的“footer.php”文件中我需要将一些 CSS 行添加到“wp_head” Hook 。我期望的工作是这样的: #foot
我想删除 wp_head 中的默认 css 样式标签,这样: 之前: ... ... ... 之后: 我怎样才能做到这一点? 最佳答案 搜索wp_enqueue_style 方法并
我正在使用@font-face 来更改默认字体。但导航菜单字体没有改变。它没有覆盖默认字体。如果我删除 wp-head() 它工作正常。但我需要 wp-head()。只有默认字体必须从 wp_head
我之前在Wordpress中使用了remove_action函数来删除wp_head注入(inject)的垃圾,但似乎在3.0版本中,一些标签没有被删除,如下所示: remove_action( 'w
我是一名优秀的程序员,十分优秀!