[英]How to make a clickable header in 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(); ?>>
<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='/'"
。 您將需要對其進行樣式設置,使其也具有cursor:pointer
,因此人們將知道它是一個鏈接。
<a href="<?php bloginfo('home'); ?>"><img src="<?php bloginfo('stylesheet_directory'); ?>/header.png"></a>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.