Hi there I seem to have run into an issue that I'm not quite sure about. I have a just developed a new WordPress theme for my personal website and I have some include files in the header which aren't being added.
<!DOCTYPE html>
<html lang="<?php language_attributes(); ?>">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="shortcut icon" href="<?php echo get_stylesheet_directory_uri(); ?>/favicon.ico" />
<title><?php wp_title(); ?></title>
<!-- Google Analytics Tracking-->
<?php include_once("/inc/google-analytics-tracking.php") ?>
<!-- Drip Tracking -->
<?php include_once("/inc/drip-tracking.php") ?>
<!-- Hotjar Tracking -->
<?php include_once("/inc/hotjar-tracking.php") ?>
<!-- ConvertFlow Tracking -->
<?php include_once("/inc/convertflow-tracking.php") ?>
<!-- Share This -->
<?php include_once("/inc/share-this.php") ?>
<?php wp_head(); ?>
</head>
You can see my site here: https://www.elliottdavidson.com/. I'm not sure why the includes arent working? If anyone could shed any light on this it would be great.
/inc/ - it's an absolute path, if you want to use relative paths you have to write this string as inc/ because / means "root" directory of the linux file system.
I figured this out, in the end, the files don't want to be added into the header.php file but into the functions.php file like so:
// Google Analytics Tracking
require get_template_directory() . '/inc/google-analytics.php';
Related
I'm struggling for days with that issue was wondering if maybe some over here can help me with that ?
I'm using the http://html5blank.com/ starter theme. I have been working on my development environment without any troubles. After updating my link for migration purpose via wp-config.php with that code :
define('WP_HOME','https://pleinsens.anatoletools.com');
define('WP_SITEURL','https://pleinsens.anatoletools.com');
After updating my link my site style-sheet doesn't apply anymore and i just can't get why.
My header.php containing the following code :
<!doctype html>
<html <?php language_attributes(); ?> class="no-js">
<head>
<meta charset="<?php bloginfo('charset'); ?>">
<title><?php wp_title(''); ?><?php if(wp_title('', false)) { echo ' :'; } ?> <?php bloginfo('name'); ?></title>
<link href="//www.google-analytics.com" rel="dns-prefetch">
<link href="<?php echo get_template_directory_uri(); ?>/img/icons/favicon.ico" rel="shortcut icon">
<link href="<?php echo get_template_directory_uri(); ?>/img/icons/touch.png" rel="apple-touch-icon-precomposed">
<link href="https://fonts.googleapis.com/css?family=Barlow+Semi+Condensed:100,100i,200,200i,300,300i,400,400i,500,500i,600,600i,700,700i,800,800i,900,900i&display=swap" rel="stylesheet">
<link href="https://fonts.googleapis.com/css?family=Poppins:100,100i,200,200i,300,300i,400,400i,500,500i,600,600i,700,700i,800,800i,900,900i&display=swap" rel="stylesheet">
<link href="https://fonts.googleapis.com/css?family=Raleway:100,100i,200,200i,300,300i,400,400i,500,500i,600,600i,700,700i,800,800i,900,900i&display=swap" rel="stylesheet">
<link href="https://fonts.googleapis.com/css2?family=Crimson+Text:ital,wght#0,400;0,600;0,700;1,400;1,600;1,700&display=swap" rel="stylesheet">
<link href="https://fonts.googleapis.com/css2?family=Barlow+Condensed:ital,wght#0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900&display=swap" rel="stylesheet">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="<?php bloginfo('description'); ?>">
Anyone could help me figure this out ? I'm totally losing my head with that issue !
Thanks in advance
The style.css would be being loaded by a function called wp_enque_script. We shouldn't see it in the header.php
Have you tried removing these lines?
define('WP_HOME','https://pleinsens.anatoletools.com');
define('WP_SITEURL','https://pleinsens.anatoletools.com');
The site's WP_HOME (where wordpress is located) might be different from it's WP_SITEURL (the url at which the site is accessed)
Because sub-domains are often hosted in sub-folders of their primary domain, try changing it to the following
define('WP_HOME','https://anatoletools.com/pleinsens');
define('WP_SITEURL','https://pleinsens.anatoletools.com');
Also, right click & view the source of the web-page, find the style.css that isn't loading & then double check the path/url that the link to the css file is pointing to matches what you expect it to & will load the style-sheet if pasted into your web-browser
Hope that helps! Here's a few more links that you may find helpful:
wordpress.stackexchange.com
Difference between wp_siteurl and wp_home
WP_HOME and WP_SITEURL
it's been some time since I did some coding so I'm basically a newbie in updated PHP (so please bear with me).
I've created a basic draft related to new web I'm working on. I decided to include header.php file (as it's supposed be used on many other pages on that web and I don't want to code header info manually for each page).
index.php file is located in main folder, css, js and images each in a separate folder: web-folders-structure .
All seems to be working fine, but when I simulate either iPad or iPhone display - menu is not resized for those type of screens (even though css styles contain detailed specs for each case).
What it should look like:
expected result
How it looks when header.php is included:
distorted navigation
index1.php start of the code:
<?php include ("./inc/header.php"); ?>
<div id="wrap">
</div>
<!-- navigation -->
content of header.php file (located in "inc" folder):
<?php
//db start
$db = mysqli_connect("localhost", "root", "", "pokus",)
or die('Error connecting to MySQL server.');
//Set DB connection charset to utf-8
$db->set_charset("utf8");
?>
<head>
<title> EGYPTICA - svet starovekeho Egypta 2019 </title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="Content-Language" content="sk">
<meta name="description" content="historia starovekeho Egypta">
<meta name="keywords" content="Egypt, staroveky Egypt, stary Egypt, Egyptica, egyptica, egyptologia, knihy, starovek, mumia, faraon, pyramidy">
<meta name="copyright" content="Copyright (c) 2019 Jana Rusnakova">
<meta name="author" content="Jana Rusnakova">
<meta name="robots" content="noindex, nofollow">
<link rel="stylesheet" href="./css/menumaker.css" type="text/css" />
<link rel="stylesheet" href="./css/main-styles.css" type="text/css" />
</head>
<body>
I tried to remove include and insert meta tags directly into index1.php and that works fine on all type of displays. However once I use include (of header) - when I check small screens (tablet, mobile phone) it doesn't work properly.
Any advise as to what could cause this?
Thx
Try adding viewport meta tag.
<meta name="viewport" content="width=device-width, initial-scale=1.0"> .
Hope it helps.
I don't think there is a problem with the inclusion of the header.php file. I would guess that the problem is with the media queries in your CSS file since the hamburger menu is not displayed and the menu items are not hidden...
I have a zend framework application up and running. I have created a layout. Now I need to include bootstrap css file to my layout.
I tried with 'baseUrl' but it didn't work. I have the css files inside 'public/assets/css'.
I also tried with tutorial in zend framework website. But it didn't work.
They mentioned to use
<?php echo $this->headLink()->appendStylesheet('/assets/css/bootstrap.css') ?>
I added the above line in layout page but it didn't work.
Also for your information when I use this headlink, in console it's showing as
Resource interpreted as Stylesheet but transferred with MIME type text/html: "http://localhost:8010/assets/css/bootstrap.css".
Any help is greatly appreciated. Thanks in advance.
Head Tag:
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Zend Framework Quickstart Application</title>
<link href="/assets/css/bootstrap.css" media="screen" rel="stylesheet" type="text/css">
</head>
Extra information: I have a controller 'HomeController' in it I have defined an action
public function homeTwoAction()
{
// action body
$this->_helper->layout->setLayout('layout');
}
In views -> I have home-two.phtml inside 'scripts/home'.
In layout I have the following code
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Bootstrap</title>
<!-- <link rel="stylesheet" href="style/bootstrap.min.css">-->
<!-- <link rel="stylesheet" href="style/customstyle.css">-->
<!--<link type="text/css" rel="stylesheet" href="/assets/css/customstyle.css">-->
<?= $this->headLink()->appendStylesheet('/assets/css/customstyle.css') ?>
<?= $this->headLink()->appendStylesheet('/assets/css/bootstrap.min.css') ?>
</head>
<body>
<div class="container-fluid">
<?php echo $this->layout()->content ?>
</div>
</body>
</html>
I am accessing
http://localhost:8010/home/home-two
HTML content is loaded but css not loading. Thanks.
Changing Mime type is explained here
Go to Tools -> Options
Then under Miscellaneous tab choose the file type css and make sure the Associated File Type is text/css
Edit
Try opening http://localhost:8010/assets/css/ or http://localhost:8010/assets/ what do you see?
I am new to HTML and hope someone can help me with this.
I am trying to set up a website where the code for every page is saved as a separate php file.
Since all these pages use the same document head and includes I would like to remove as much as possible of this from the pages and save it in a separate includes file (header.php) which I can then include using PHP.
My current head looks as follows and since this is the same on all pages I currently have ALL this saved in the separate header.php file and then just use <?php include "header.php"; ?> on the single pages.
Can someone tell me which parts of this should remain on the single pages for a proper setup and if anything should be changed or added here ?
Note: jQuery and JS are included separately in the footer.
My PHP (header file):
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="author" content="John Doe" />
<meta name="description" content="Created: 2015-06" />
<base href="http://www.MyURL.com" target="_self" />
<!-- CSS -->
<link rel="stylesheet" type="text/css" href="includes/styles.css" />
<!-- CSS - Font Awesome -->
<link rel="stylesheet" type="text/css" href="http://maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css" />
<title>My Page</title>
</head>
<body>
<div class="wrapper">
<!-- ... -->
Your Top head file (top_head.php):
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<?php if(isset($page_author)){ ?>
<meta name="author" content="<?php echo $page_author; ?>" />
<?php } ?>
<?php if(isset($page_description)){ ?>
<meta name="description" content="Created: 2015-06" />
<?php } ?>
<!-- CSS -->
<link rel="stylesheet" type="text/css" href="includes/styles.css" />
<!-- CSS - Font Awesome -->
<link rel="stylesheet" type="text/css" href="http://maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css" />
<title><?php echo $page_title; ?></title>
Your current header file:
<?php
$page_title = 'Hello';
$page_description = 'This is a beautiful description';
?>
<?php include("top_head.php"); ?>
</head>
<body>
<div class="wrapper">
<!-- ... -->
Since you are starting your tag in header.php, you can close the tag on the own page itself (i mean the other pages ie: Contact, About Us, Product, etc...).
The code section you have mentioned in the question can be called as header.php and further can be included on each and every page where it is required.
Apart from this
Header - header.php
Main content - main-content.php - this will be specific to each and every page from your website
Footer - footer.php - this can also be made common - and further included in every page.
Apart from this you can also have a few more php files which might have navigation or any kind of common content blocks.
Example page could be:
<?php
include 'header.php'
/*either add here the content or include further php files*/
include 'about-us.php'
include 'footer.php'
?>
You are doing right, the parts that are shared between all the pages should be placed in a separate php file, this greatly improve your life when you have to maintain the site (immagine add a stylesheet or a library to every page of your site after some time ...).
To help SEO you should specify a title and maybe some meta tag that are page specific.
Also consider carefully if you have other parts that are repeated in every page for example a left or right bar or a particular widget (for example a banner image or something like that)
This should give you the general idea...
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="author" content="John Doe" />
<meta name="description" content="Created: 2015-06" />
<base href="http://www.MyURL.com" target="_self" />
<!--
Your paths need to relative to the websites root directory or the full
URL else they may not work depending on where the file is located.
-->
<link rel="stylesheet" type="text/css" href="/includes/styles.css" />
<link rel="stylesheet" type="text/css" href="http://maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css" />
<!--
This line just echos the title if one has been set or a default string
if the title hasn't been set. You will need to ensure every page that
includes this file sets the title before including this file. You may
also want to take this approach with other values.
-->
<title><?php echo isset($title) ? $title : 'Default Title'; ?></title>
</head>
<body>
<div class="wrapper">
How do I set a base URL for my website and get it to include in every page?
Is there a way for me to easily change a variable to be the base url for the website, such as <?php $baseurl = "http://www.website.com/website/"; ?>, and include this on every page so that all CSS, JavaScript, images and PHP includes follow this $baseurl?
You can’t make both PHP and client-side assets use the same base URL, unless you use PHP to echo a base URL variable or constant to the page.
The usual approach is to have a bootstrap file that you include on every page, and define your base URL and other site-wide variables in there.
bootstrap.php:
<?php
define('BASE_URL', 'http://example.com');
index.php:
<?php
include('bootstrap.php');
?>
<!DOCTYPE html>
<html>
<head>
<!-- // -->
<link rel="stylesheet" href="<?php echo BASE_URL; ?>/css/styles.css" />
</head>
<body>
<!-- // -->
</body>
</html>
You may want to take a look at the html base tag.
Inside the <head> section of your html, put
<base href="http://www.website.com/website/">
On top of that, you may want to have a base.php with default directories and whatnot that you include into your project.
(xampp), the
How do I use on the local computer.
folder layout,
http://www.resimagaci.com/img/90rvnrf.png
ust.php
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title></title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width">
</head>
<body>
alt.php
</body>
</html>
sabitler.php
<?php
#sabitler
define('BASE_URL', 'base-url');
?>
index.php
<?php
include 'kutuphane/sabitler.php';
?>
<?php
$ust= BASE_URL . '/kutuphane/ust.php';
$alt= BASE_URL . '/kutuphane/alt.php';
?>
<?php
include ($ust);
?>
<?php
include ($alt);
?>