Php 如何在wordpress中制作可点击的标题?

Php 如何在wordpress中制作可点击的标题?,php,wordpress,Php,Wordpress,如何使Wordpress标题图像可单击,以便导航到主页 这是我的header.php文件: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" <?php language_attributes()

如何使Wordpress标题图像可单击,以便导航到主页

这是我的header.php文件:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" <?php language_attributes(); ?>>

<head profile="http://gmpg.org/xfn/11">
    <title><?php
        if ( is_single() ) { single_post_title(); }      
        elseif ( is_home() || is_front_page() ) { bloginfo('name'); print ' | '; bloginfo('description'); get_page_number(); }
        elseif ( is_page() ) { single_post_title(''); }
        elseif ( is_search() ) { bloginfo('name'); print ' | Search results for ' . wp_specialchars($s); get_page_number(); }
        elseif ( is_404() ) { bloginfo('name'); print ' | Not Found'; }
        else { bloginfo('name'); wp_title('|'); get_page_number(); }
    ?></title>

 <meta http-equiv="content-type" content="<?php bloginfo('html_type'); ?>; charset=<?php bloginfo('charset'); ?>" />

 <link rel="stylesheet" type="text/css" href="<?php bloginfo('stylesheet_url'); ?>" />

 <?php if ( is_singular() ) wp_enqueue_script( 'comment-reply' ); ?>

 <?php wp_head(); ?>

 <link rel="alternate" type="application/rss+xml" href="<?php bloginfo('rss2_url'); ?>" title="<?php printf( __( '%s latest posts', 'your-theme' ), wp_specialchars( get_bloginfo('name'), 1 ) ); ?>" />
 <link rel="alternate" type="application/rss+xml" href="<?php bloginfo('comments_rss2_url') ?>" title="<?php printf( __( '%s latest comments', 'your-theme' ), wp_specialchars( get_bloginfo('name'), 1 ) ); ?>" />
 <link rel="pingback" href="<?php bloginfo('pingback_url'); ?>" />
</head>

<body>
<div id="wrapper" class="hfeed">
 <div id="header">
  <div id="masthead">

   <div id="branding">
      <a href="<?php echo get_option('home'); ?>/" title="<?php bloginfo('name'); ?> | <?php bloginfo('description'); ?>"></a>
      </a></span></div>
<?php if ( is_home() || is_front_page() ) { ?>
       <a href="<?php echo get_option('home'); ?>/" title="<?php bloginfo('name'); ?> | <?php bloginfo('description'); ?>"></a>
<?php } else { ?>
        <a href="<?php echo get_option('home'); ?>/" title="<?php bloginfo('name'); ?> | <?php bloginfo('description'); ?>"></a>
<?php } ?>
   </div><!– #branding –>

   <div id="access">
   </div><!– #access –>

  </div><!– #masthead –>
 </div><!– #header –>

 <div id="main">


要单击哪个div,请添加
onclick=“window.location.href=”/“
。您需要对其进行样式设置,使其也具有
光标:指针
,以便人们知道它是一个链接。


<a href="<?php bloginfo('home'); ?>"><img src="<?php bloginfo('stylesheet_directory'); ?>/header.png"></a>

我假设标题图像是div的背景,而不是img标记中的背景。你不能把
a
放在
div
周围,因为
a
不是块级元素。是的,但是这样做对SEO和没有启用javascript的人来说通常是个坏主意。不,但是你可以在
div
中放置一个空的
a
,它有
显示:block
和图像集的宽度/高度,这将在没有javascript和搜索引擎的情况下工作。