WordPress theme-create header.php
Next, create a new PHP file header.php in the theme directory wp-content\themes\bbbbf we created last time. We extract the header code in index.php and copy and paste it into header.php. The following code is all the code in header.php (of course, the header code of different themes is different, and you can decide it yourself in your actual project):
<!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”>
<head profile=”http://gmpg.org/xfn/11″>
<meta http-equiv=”Content-Type” content=”text/html; charset=utf-8″ />
<title>Aurelius | Blog</title> <!– Stylesheets –> <link rel=”stylesheet” href=”./style.css” type=”text/css” media=”screen” /> </head> <body> <div id=”wrapper” class=”container_12 clearfix”> <!– Text Logo –> <h1 id=”logo” class=”grid_4″>BBBBF</h1> <!– Navigation Menu –> <ul id=”navigation ” class=”grid_8″> <li><a href=”contact.html”><span class=”meta”>Get in touch</span><br /> Contact Us</a></li> <li><a href=”blog.html” class=”current”><span class=”meta”>Latest news</span><br /> Blog</a></li> <li><a href=”index.html”><span class=”meta”>Homepage</span><br />
Home</a></li>
</ul>
<div class=”hr grid_12 clearfix”> </div>
<!– Caption Line –>
<h2 class=”grid_12 caption clearfix”>Our <span>blog</span>, keeping you up-to-date on our latest news.</h2>
<div class=”hr grid_12 clearfix”> </div>
~~~
Open index.php, archive.php, contact.php, full_width.php, page.php and single.php with a text editor, delete the above similar code, and change it to:
~~~
<?php get_header(); ?>
~~~
Let’s modify header.php together:
**1. Change <title>**
We all know that the titles of different pages are different, and the title setting will directly affect the SEO effect, so it should be set carefully here. Here is a SEO-optimized title writing method. Change <title>BBBBF | Blog</title> to:
~~~
<title><?php if ( is_home() ) {
bloginfo(‘name’); echo ” – “; bloginfo(‘description’);
} elseif ( is_category() ) {
single_cat_title(); echo ” – “; bloginfo(‘name’);
} elseif (is_single() || is_page() ) {
single_post_title();
} elseif (is_search() ) {
echo “search results”; echo ” – “; bloginfo(‘name’);
} elseif (is_404() ) {
echo ‘page not found!’;
} else {
wp_title(”,true);
} ?></title>
~~~
The php code added above uses conditional judgment and uses different titles for different pages. Here are some explanations of these conditional tags.
* is_home(): Returns true if the current page is the homepage
* is_category(): Returns true if the current page is a category page
* is_single(): Returns true if the current page is a single article page
* is_page(): Returns true if the current page is a single page
* For more details, see the WordPress documentation: Conditional Tags
Search
Popular on Blogar
Content Marketing-What is Content Marketing
- October 24th, 2023
- 1415 Views
Social Media Marketing-Social Media Marketing (SMM)
- October 24th, 2023
- 1706 Views
Pay-Per-Click-What is PPC
- October 24th, 2023
- 1279 Views
WordPress-How to show single post content in front-end?
- August 26th, 2024
- 99 Views
WordPress display articles by category
- August 28th, 2024
- 93 Views
How To Find The IP Of Any Whatsapp Call
- September 3rd, 2024
- 91 Views
WordPress-How to create a Taxonomy?
- August 28th, 2024
- 88 Views
WordPress next post / previous post on the same category
- November 11th, 2024
- 86 Views
Social Media Marketing – 53 Resources For First Time Entrepreneurs
- October 24th, 2023
- 808 Views
Email Marketing-Advantages and disadvantages of email marketing
- October 24th, 2023
- 761 Views
Recent Post
Content Marketing-What is Content Marketing
- October 24th, 2023
- 1415 Views
Social Media Marketing-Social Media Marketing (SMM)
- October 24th, 2023
- 1706 Views
Pay-Per-Click-What is PPC
- October 24th, 2023
- 1279 Views
VMware cannot install VMware Tools, prompts VMCI, memory driver
- November 25th, 2024
- 67 Views
- Howo Tractor Truck
- Howo Tipper/Dump Truck
- Howo Cargo Truck
- Howo Concrete Mixer Truck
- Howo Special Truck
- Howo Light Truck
- Shacman Tractor Truck
- Shacman Tipper/Dump Truck
- Shacman Cargo Truck
- Shacman Concrete Mixer Truck
- LGMG Mining Trucks
- XCMG Wheel Loader
- XCMG Excavator
- XCMG Crane
- XCMG Asphalt Pavers
- XCMG Road Roller
- Shantui Bulldozer
Copyright © 2024 BBBBF All Rights Reserved.