I am starting with wordpress and after adding dynamic heading <?php wp_head(); ?> everything in the body disappears.
this is my header.php file
<!DOCTYPE html>
<html <?php language_attributes(); ?>>
<head>
<meta charset="<?php bloginfo('charset');?>">
<title><?php bloginfo('name');?> | <?php wp_title();?></title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="<?php bloginfo('template_url'); ?>/css/bootstrap.css" rel="stylesheet">
<link href="<?php bloginfo('stylesheet_url'); ?>" rel="stylesheet">
<?php wp_head(); ?>
</head>
When I remove the <?php wp_head(); ?> line, everything in the body shows. I am told that including the line is a must in wordpress.
On your header.php you have to call:
<?php wp_head(); ?>
On your internal pages, like index.php you have to call:
<?php get_header(); ?>
See:https://codex.wordpress.org/Theme_Development
Also you can turn your debug mode on in order to identify the errors.
https://codex.wordpress.org/Debugging_in_WordPress
Related
I'm trying to create my new own theme for wordpress (and the first one) and I encounter that my site isn't loading the header nor the content of index.php. It's pretty strange, I've read the WP WSoD documentation but I couldn't find anything helpful since my theme only have a couple of lines, I don't see the problem.
This is my theme structure:
And I've only edited index.php, header.php and footer.php. My functions.php seems to have something but I just added some lines to test, it's now blank again.
And this is what's inside my header.php:
<!DOCTYPE html>
<html lang="es">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<title> <?php bloginfo( 'name' ); ?> </title>
<!-- Bootstrap CSS -->
<link rel="stylesheet" href="<?= get_template_directory_uri() ?>/assets/css/bootstrap.min.css">
<!-- Natural Stylesheet -->
<link rel="stylesheet" href="<?= get_template_directory_uri() ?>/style.css">
<!-- Font Awesome -->
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.5.0/css/all.css" integrity="sha384-B4dIYHKNBt8Bc12p+WXckhzcICo0wtJAoU8YZTY5qE0Id1GSseTk6S+L3BlXeVIU" crossorigin="anonymous">
<!-- Favicon -->
<link rel="shortcut icon" type="image/png" href="<?= get_template_directory_uri(); ?>/assets/img/favicon.png"/>
</head>
<body>
This is what's inside my footer.php:
<script type="text/javascript" src="<?= get_template_directory_uri(); ?>/assets/js/jquery-3.3.1.min.js"></script>
<script type="text/javascript" src="<?= get_template_directory_uri(); ?>/assets/js/popper.js"></script>
<script type="text/javascript" src="<?= get_template_directory_uri(); ?>/assets/js/bootstrap.min.js"></script>
</body>
</html>
And this is what I've inside my index.php:
<?php get_header(); ?>
<?php while( have_posts() ) the_post(); ?>
<?php get_footer(); ?>
I edited index.php and WordPress was loading front-page.php
How can i remove the <meta http-equiv="content-type" content="text/html; charset=utf-8" />
on this PHP Joomla Template? Because I have a Duplication of the Meta Tag from Joomla and from the Template :/ The Head.php file it is calling is:
<meta charset="<?php echo $this['system']->document->getCharset(); ?>">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<?php if($this['config']->get('responsive', true)): ?>
<meta name="viewport" content="width=device-width, initial-scale=1">
<?php endif; ?>
<?php if (isset($error)): ?>
<title><?php echo $error; ?> - <?php echo $title; ?></title>
<?php else: ?>
<jdoc:include type="head" />
<?php endif; ?>
and the Index.php is:
// get theme configuration
include($this['path']->path('layouts:theme.config.php'));
?>
<!DOCTYPE HTML>
<html lang="<?php echo $this['config']->get('language'); ?>" dir="<?php echo $this['config']->get('direction'); ?>" data-config='<?php echo $this['config']->get('body_config','{}'); ?>'>
<head>
<?php echo $this['template']->render('head'); ?>
</head>
<body class="<?php echo $this['config']->get('body_classes'); ?>">
here is an Image of this Problem:
Link to the Problem ( imgur )
If i understand your problem right. Do you want to remove the duplicate chartset?
Simple remove the first line in your first code sample.
And you can try $doc->setHtml5(true);in the index.php
I was just working with wordpress and managed to get my site up. Now i am getting this unnecessary header in my site (the black header ... right at the top), see below:
.
My header code looks like below:
<!doctype html>
<html <?php language_attributes(); ?> >
<head>
<meta charset="<?php bloginfo('charset'); ?>">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<title><?php bloginfo('name'); ?></title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="shortcut icon" type="image/x-icon" href="favicon.ico">
<link rel="stylesheet" href="style.css">
<?php wp_head(); ?>
</head>
<body <?php body_class(); ?>>
<header class="site-header">
<h1><?php bloginfo('name'); ?></h1>
<h5><?php bloginfo('description'); ?></h5>
<nav class="site-nav">
<?php
$args = array(
'theme_location' => 'primary'
);
?>
<?php wp_nav_menu($args); ?>
</nav>
</header>
I am new to workpress and just beginning to learn stuff.
How can i remove this header?
Thank you.
Wordpress shows this admin bar by default when you are logged in in the backend. Non-admin users will not see it, but you can disable this in your profile if you want.
Go to Users -> Your profile
Disable the option Show toolbar when viewing site
remove this line, the header will goes hide
<?php wp_head(); ?>
I am learning WordPress and basically I have this very simple site, I have the following header file:
<!doctype html>
<html <?php language_attributes(); ?> >
<head>
<meta charset="<?php bloginfo('charset'); ?>">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<title><?php bloginfo('name'); ?></title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="shortcut icon" type="image/x-icon" href="favicon.ico">
<link rel="stylesheet" href="style.css">
<?php wp_head(); ?>
</head>
<body <?php body_class(); ?>>
<header class="site-header">
<h1><?php bloginfo('name'); ?></h1>
<h5><?php bloginfo('description'); ?></h5>
<nav class="site-nav">
<?php
$args = array(
'theme_location' => 'primary'
);
?>
<?php wp_nav_menu($args); ?>
</nav>
</header>
Now I believe, the menu is actually created by the below line of code:
<?php wp_nav_menu($args); ?>
Now when I check in the Front End, i.e. I load my site, I see that the only item in my menu is "sample-page", I was following from 1:38 onwards HERE and you'll see how this guy get a menu with "about us", "home", "contact" etc…
Now why am I not getting the same and how can I create those menus?
To create your own menu, you need to first go to your wp-admin dashboard. Then go to Appearance/menus.
Here you can create your own menus, or modify existing menus. After you do this, choose the role of the menu from the near footer of the page, just before the "Save menu" option.
And I hope you're all done!
Your code is attaching the 'primary' theme location to wp_nav_menu. Go to your dashboard Appearance>Menu page and see if you have a Primary menu in
the dropdown next to 'Select a menu to edit'. If so, select it. The pages in that menu should show. You can add to them as needed.
I am trying to get more control over the header of my Joomla site; for some pages I don't need many things in the header. I decided to make a template where I don't use the <jdoc:include type="head" />, because it loads lot of things that I don't need.
Searching, I found this old post about the subject, and in the web some people looking for the same thing. Manually control <head> markup in Joomla
I was wondering if it is possible to add to my index.php template file to PHP code that could get just the "metadescription" and the "title" of the Joomla publication. Something like this:
<?php defined( '_JEXEC' ) or die; ?>
<!doctype html>
<html lang="<?php echo $this->language; ?>">
<head>
<meta name="viewport" content="width=device-width />
<meta name="description" content="<?php echo **code metadescription** ?>" />
<title><?php echo **code to get title** ?></title>
</head>
<body>
<jdoc:include type="component" />
</body>
</html>
Nice, after while i could find the code that i was looking for, and maybe it could help others, it worked for me... in the index.php file of the template i added:
<?php defined( '_JEXEC' ) or die;
$doc =JFactory::getDocument();
$meta_description = $doc->getMetaData("description");
$title = $doc->getTitle();
?>
<!doctype html>
<html lang="<?php echo $this->language; ?>">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" />
<meta name="description" content="<?php echo "$meta_description"; ?>" />
<title><?php echo "$title" ?></title>
</head>
<body> <jdoc:include type="component" /> </body>
</html>
Just use PHP include() function
In top.php
<meta name="viewport" content="width=device-width />
<meta name="description" content="<?php echo **code meta description** ?>" />
<title><?php echo **code to get title** ?></title>
And in your current file just include the file(top.php) like
<?php defined( '_JEXEC' ) or die; ?>
<!doctype html>
<html lang="<?php echo $this->language; ?>">
<head>
<?php include("top.php"); ?>
</head>
<body>
<jdoc:include type="component" />
</body>
</html>
I don't know if this is a good way, but you can unset all css and js in the following style:
unset($doc->_styleSheets[$this->baseurl.'/path/to/some.css']);
unset($doc->_scripts[$this->baseurl.'/path/to/some.js']);
I recommend not to remove meta tage like content-type or x-ua-compatible. These tags support your website in some browsers. And the favicon link is helpful by bookmarks.