douxu0550 2010-08-25 22:17
浏览 36
已采纳

更改自定义Wordpress集成页面的标题

When I need to add a custom page to Wordpress based site I always load the theme's header first:

<?php
  require('../wp-blog-header.php');
  include('../wp-content/themes/mytheme/header.php');
?>

Unfortunately then every custom page gets the same title (the blog's name) due to this code in header.php:

<head>
<title><?php if(is_home()) { bloginfo('name');} else { bloginfo('name'); echo ' | '; the_title(); } ?></title>

What would be the best way to change this page title?

  • Is there a wordpress method to call before loading the header that will change the_title()'s return value?
  • Should I change the header.php call so it will check if there is a previously defined custom value for my title?

Thanks,

  • 写回答

2条回答 默认 最新

  • dongwai4434 2010-09-30 03:02
    关注

    Actually you can look at your header code like this:

    <?php
        if (is_home()) {
             bloginfo('name');
       } else {
             bloginfo('name'); echo ' | '; the_title();
        } ?>
    

    Translating: if (it is your home) then print the blog's name. Else, print the blog's name, a | bar and the page/post title.

    Is it printing ONLY the blog's name on custom pages or is it performing correctly?

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥20 access多表提取相同字段数据并合并
  • ¥20 基于MSP430f5529的MPU6050驱动,求出欧拉角
  • ¥20 Java-Oj-桌布的计算
  • ¥15 powerbuilder中的datawindow数据整合到新的DataWindow
  • ¥20 有人知道这种图怎么画吗?
  • ¥15 pyqt6如何引用qrc文件加载里面的的资源
  • ¥15 安卓JNI项目使用lua上的问题
  • ¥20 RL+GNN解决人员排班问题时梯度消失
  • ¥60 要数控稳压电源测试数据
  • ¥15 能帮我写下这个编程吗