Wordpress:在每个页面的不同位置添加徽标

问题描述 投票:0回答:1

我想在网站的标题中加上一个标识。我使用的主题是“雪鸟”。在header.php中,我想根据网站的每个页面指定Wordpress将徽标放在标题上的不同位置。

这是我添加到header.php的代码

<!DOCTYPE html>
<!--[if IE 9]>
<html class="ie9" <?php language_attributes(); ?>><![endif]-->
<!--[if gt IE 9]><!-->
<html <?php language_attributes(); ?>><!--<![endif]-->
<head>
<?php wp_head(); ?>
</head>

<body <?php body_class(); ?> itemtype="http://schema.org/WebPage" itemscope="itemscope">

<div class="xf__site hfeed">
   <div class="content-area">
      <div class="logo">
         <a href="#"><img src="https://website/wp-content/uploads/2017/09/logo-website.png" alt="Logo" /></a>
      </div>

我怎样才能做到这一点 ?

最好的看法,Lordaker

php wordpress header
1个回答
0
投票

使用body_class过滤器将类添加到特定页面的body元素,然后使用CSS进行定位。

PHP - functions.php

function wp_body_classes( $classes ) {
  if ( is_page( 'Demo Page' ) ) {
    $classes[] = 'demo-page';
  }
  return $classes;
}
add_filter( 'body_class', 'wp_body_classes' );

CSS

.demo-page .logo {
   // position
}
© www.soinside.com 2019 - 2024. All rights reserved.