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
Related
I have a Wordpress website with a custom theme. Everything works fine on index.php but when I create one more page (index2.php or adminpage.php) and try to load that in-browser WordPress will redirect me to index.php
OK, this is file setup: https://ibb.co/9n7Qdxt . This is URL of normal index.php: https://ibb.co/M69f5bD . And this is a problem: https://ibb.co/kJFW4ZZ
ps: adminpage.php is empty but browser load index.php
image: https://ibb.co/x2T82dc
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<META HTTP-EQUIV="CACHE-CONTROL" CONTENT="NO-CACHE">
<META HTTP-EQUIV="EXPIRES" CONTENT="Mon, 22 Jul 2002 11:12:01 GMT">
<link rel="icon" href="favicon.ico">
<link rel="icon" href="favicon.png">
<title></title>
<?php wp_head(); ?>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<link href="https://fonts.googleapis.com/css?family=Lato:100,100i,300,300i,400,400i,700,700i,900,900i" rel="stylesheet">
<link href="https://fonts.googleapis.com/css?family=Libre+Franklin:100,100i,200,200i,300,300i,400,400i,500,500i" rel="stylesheet">
<link href="https://fonts.googleapis.com/css?family=Montserrat" rel="stylesheet">
</head>
PRoblem: Wordpress always redirects the user to index.php regardless which url user enter ...
From what you've described you haven't added the adminpage.php as a template file and assigned it to a page in the backend. Here's a link to help you with template theming in WordPress.
https://developer.wordpress.org/themes/basics/template-hierarchy/
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';
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">
I am currently using codeigniter to write out templates for a website. The problem is that I'm trying to achieve absolute paths for attributes such as href and src, but they aren't working. I've checked my results, and the link's and scripts point through the correct directory, so I'm not sure why there is a problem.
This is the code I'm using below:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Home</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="">
<link rel="stylesheet" href="<?php echo base_url() . "assets/bootstrap/css/bootstrap.css"; ?>">
<link rel="stylesheet" href="<?php echo base_url() . "assets/bootstrap/css/bootstrap-responsive.css"; ?>">
<!-- HTML5 shim, for IE6-8 support of HTML5 elements -->
<!--[if lt IE 9]>
<script src="<?php echo base_url() . "assets/html5shiv/html5shiv.js"; ?>"></script>
<![endif]-->
<!-- Fav and touch icons go here -->
</head>
<body>
<p>This comes from the header view.</p>
<button class="btn btn-primary">Primary</button>
<br />
<a class="btn btn-primary">Secondary</a>
I can tell that this isn't working because I'm trying to use bootstrap to style two buttons, but they aren't working. Can someone please help me figure this out?
Oh, by the way..my base_url is http://localhost/ProjectName/, and I know that I have this working correctly because I have enabled the URL helper and I am able to echo the base_url.
Please make sure that You've loaded URL helper, in your autoload.php, and also make sure that you've added defined base_url in your config.php.
if not then this should help you out.
I think you haven't edited codeigniter files to enable base_url(). you try to assingn it in url_helper.php you also can do the same config/autoload.php file. you can add this code in your autoload.php
$autoload['helper'] = array('url');
There's no need to drop in and out of PHP. You can just do this:
<link rel="stylesheet" href="/assets/bootstrap/css/bootstrap.css" />
if this doesn't work there's a problem with where your css files are.
So this is my first post! I've just created the account, but I always check on here to solve my problems.
I've found others with the same problem but the solutions haven't been working for me.
So I have on the .PHP file all the content correctly placed on the head tag but for some reason it is going into the body tag leaving my first one empty.. And it adds a strange
"
" (text space) on the beginning of the body.
What could it be?
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title><?php bloginfo('name'); ?> <?php if ( is_single() ) { ?> <?php } ?> <?php wp_title(); ?></title>
<meta name="generator" content="WordPress <?php bloginfo('version'); ?>">
<link rel="stylesheet" href="<?php bloginfo('stylesheet_url'); ?>" type="text/css" media="screen">
<link rel="alternate" type="application/rss+xml" title="RSS 2.0" href="<?php bloginfo('rss2_url'); ?>">
<link rel="alternate" type="text/xml" title="RSS .92" href="<?php bloginfo('rss_url'); ?>">
<link rel="alternate" type="application/atom+xml" title="Atom 0.3" href="<?php bloginfo('atom_url'); ?>">
<link rel="pingback" href="<?php bloginfo('pingback_url'); ?>">
</head>
<body>
Easy Solution
Open your head containing file with Notepad++
Click on encoding, select Encode in UTF-8 Without BOM
It fixes the issue.
This is most likely caused by an error introducing some text content into the head area.
It is very hard to identify where that is given the PHP instead of the generated HTML, but a validator should pick it up.
(Posted on behalf of the OP.)
Fixed. The problem was that the files were with BOM (Byte-Order Mark). Re-saving all files without the BOM solved it.
The simple solution of this issues is, first open your header.php with (NotePad++ Windows application, or any software that you use for programming PHP files) and move to menu (Encoder) and set (Encoder UTF-8 (sans BOM)).
I have the same problem before but I'm trying to fix it by deleting JS and CSS files and the problem still not fixed.