Jump to content

Recommended Posts

i am a beginner and learning wordpress. Codex is not for beginners the information there is in the form of notes, something that is very difficult to be grasped for any beginner.

 

I have few question, This is from header.php - 

<!DOCTYPE html>
<html <?php language_attributes(); ?>>
	<head>
		<meta charset="<?php bloginfo('charset'); ?>">
		<meta name="viewport" content="width=device-width">
		<title><?php bloginfo('name'); ?></title>
		<?php wp_head(); ?>
	</head>
	
<body <?php body_class(); ?>>
	
	<div class="container">
	
		<!-- site-header -->
		<header class="site-header">
			<h1><a href="<?php echo home_url(); ?>"><?php bloginfo('name'); ?></a></h1>
			<h5><?php bloginfo('description'); ?></h5>
		</header><!-- /site-header -->

Why is this part used twice - 

<?php bloginfo('name'); ?>

 

First in head section - 

<title><?php bloginfo('name'); ?></title>

 

then in Body - 

<h1><a href="<?php echo home_url(); ?>"><?php bloginfo('name'); ?></a></h1>

Link to comment
https://forums.phpfreaks.com/topic/294821-basic-word-pres-syntax-help-needed/
Share on other sites

Why is this part used twice - 

<?php bloginfo('name'); ?>

 

The bloginfo() function prints the result directly to the screen. So it needs to be called every time you want that value.

 

However, you could assign the value to a variable by using get_bloginfo(). Then just use the variable wherever you want. More information can be found here:

http://codex.wordpress.org/Function_Reference/get_bloginfo

 

The first one is the title of the document which is a hidden element of the page to a visiting user and used by browsers and search engines

<title><?php bloginfo('name'); ?></title>

 

The other one in body they are using as the title of your blogs home href link which is visible.

This is way of automating the creation of your home link

<h1><a href="<?php echo home_url(); ?>"><?php bloginfo('name'); ?></a></h1>

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.