1

我是土耳其博主。我有一个 wordpress 博客。我博客的 404.php 页面的标题是“没有找到 %value%”,我想更改它。我无法从 header.php 中的标题标签更改它。那我该怎么办?

问题图片

这是我在头标签之间的代码

    <link rel="stylesheet" type="text/css" href="<?php bloginfo('template_url'); ?>/css/fontello.css" />
<script type="text/javascript" src="<?php bloginfo('template_url'); ?>/js/jquery.min.js"></script>
<meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php bloginfo('charset'); ?>" />
<title>
    <?php 
        if( is_404() ) {
            echo 'Error 404 - Page Not Found | '; // or Whatever you want
            bloginfo('name');
        }
        else
        { 
          wp_title( '|', true, 'right'); //bloginfo('name'); ?> <?php if ( is_single() ) { ?> &raquo; <?php } ?> <?php wp_title();
        }
    ?>
  </title>
<meta name="keywords" content="" />
<meta name="description" content="" />
<meta name="robots" content="index, follow" />
<?php wp_get_archives('type=monthly&format=link'); ?>
<link rel="alternate" type="application/rss+xml" title="RSS 2.0" href="<?php bloginfo('rss2_url'); ?>" />
<link rel="alternate" type="text/xml" title="RSS .92" href="<?php bloginfo('rss_url'); ?>" />
<link rel="alternate" type="application/atom+xml" title="Atom 0.3" href="<?php bloginfo('atom_url'); ?>" />
<link rel="pingback" href="<?php bloginfo('pingback_url'); ?>" />
<link rel="profile" href="http://gmpg.org/xfn/11" />
<?php if ( is_singular() ) wp_enqueue_script( 'comment-reply' ); ?>
<link rel="stylesheet" type="text/css" media="all" href="<?php bloginfo('stylesheet_url'); ?>" />
<link rel="shortcut_icon" href="<?php bloginfo('template_url'); ?>/css/img/favicon.ico" />
<?php wp_head(); ?>
4

2 回答 2

1

试试这个if statement

更新

<title>
    <?php 
        if( is_404() ) { // if it's 404 page

            echo 'Error 404 - Page Not Found | '; // or Whatever you want

            bloginfo('name');

        } else if( is_single() ) { // if it's single (post)

            echo '&raquo;';   

            wp_title();            

        } else { 

            wp_title( '|', true, 'right'); 

        }
    ?>
</title>
于 2013-10-13T15:53:15.230 回答
0
function change_404_title(){

    if(is_404())
    return "your custom title here"; 
}

add_filter( 'wp_title', 'change_404_title', 10, 1 );
于 2013-10-13T17:08:39.863 回答