I'm working on a wordpress site, which has suddenly stopped working. Blank pages everywhere. It is a fresh site, and only I've made changes to it. The issue occured while I was building a custom template. This is the error message when I try to clear the cache with wp cache flush
PHP Warning: mysqli_real_connect(): (HY000/2002): No such file or directory in /Users/Jillian/sites/wp2/site/web/wp/wp-includes/wp-db.php on line 1538
Warning: mysqli_real_connect(): (HY000/2002): No such file or directory in /Users/Jillian/sites/wp2/site/web/wp/wp-includes/wp-db.php on line 1538
Error: Error establishing a database connection. This either means that the username and password information in your `wp-config.php` file is incorrect or we can’t contact the database server at `localhost`. This could mean your host’s database server is down.
Maybe someone with more wordpress experience than me can shed light on the problem?
Here are all the culprits:
Custom template: Test template
<!-- http://wp2.dev/44-2/ -->
<?php /* Template Name: Test Template */
function mypage_head() {
echo '<link rel="stylesheet" type="text/css" href="'.get_bloginfo('stylesheet_directory').'/sass/style.css">'."\n"
}
add_action('wp_head', 'mypage_head');
get_header();
$page = get_post_meta(44);
// Dsiplay the page title (without >> in front)
$header = $page['header'][0];
$subheader = $page['subheader'][0];
?>
<section class="span12" id="HomeHeader">
<h1><?php echo $header; ?></h1>
<div class="subtext"><?php echo $subheader; ?></div>
</section>
<section class="span12" id="HomeProjects">
<?php
// Display all projects
$args = array('post_type' => 'project');
$posts = get_posts($args);
foreach($posts as $post) {
$category = get_field('category');
$title = the_title();
$description = get_field('description');
$link = get_field('link');
$link_title = get_field('link_title');
$image = get_field('image');
?>
<div class="project">
<?php if( !empty($image) ): ?>
<div class="project-image-container">
<img src="<?php echo $image['url']; ?>" />
</div>
<?php endif; ?>
<div class="subtext category"><?php echo $category; ?></div>
<h2><?php $title; ?></h2>
<div class="content"><?php echo $description; ?></div>
<a href="<?php echo $link; ?>" class="read-more"><?php echo $link_title; ?></a>
</div>
<?php
}
?>
</section>
<section class="span12" id="HomeClients">
<h1>Clients</h1>
<?php
//Display all clients
$args = array('post_type' => 'client');
$posts = get_posts($args);
foreach($posts as $post) {
// $title = the_title();
$icon = get_field('icon');
$url = get_field('link');
$alt = $icon['alt'] ? $icon['alt'] : get_field('title');
?>
<div class="client">
<?php if( !empty($icon) ): ?>
<div class="client-img-container">
<img src="<?php echo $icon['url']; ?>" alt="<?php $alt; ?>" />
</div>
<?php endif; ?>
<a href="<?php echo $url; ?>">link</a>
</div>
<?php
}
?>
</section>
<section class="span12" id="HomeNews">
<?php
// Display news section
$title = $page['title'][0];
$content = $page['content'][0];
$news_link = $page['news_link'][0];
$news_link_title = $page['news_link_title'][0];
$args = array('post_type' => 'post'); // Query just regular posts
$posts = get_posts($args);
?>
<div class="posts">
<div class="subtext">Latest</div>
<?php
foreach($posts as $post) {
// setup_postdata($post);
$date = date_format(date_create($post->post_date), 'jS F Y');
?>
<div class="date"><?php echo $date; ?></div>
<div class="content"><?php $post->post_content; ?></div>
<?php
}
?>
</div>
<div class="news">
<h2><?php echo $title ?></h2>
<div class="content"><?php echo $content ?></div>
<div class="btn news-link"><a href="<?php echo $news_link ?>"><?php echo $news_link_title ?></a></div>
</div>
</section>
<section class="span12" id="HomeCTA">
<?php
// Display CTA section
$tagline = $page['tagline'][0];
$bold_text = $page['bold_text'][0];
$body = $page['body'][0];
$cta_link = $page['cta_link'][0];
$cta_link_title = $page['cta_link_title'][0];
?>
<div class="cta">
<div class="subtext"><?php echo $tagline ?></div>
<h2 class="bold-text"><?php echo $bold_text ?></h2>
<div class="content news-body"><?php echo $body ?></div>
<div class="btn cta-link"><a href="<?php echo $cta_link ?>"><?php echo $cta_link_title ?></a></div>
</div>
</section>
<section class="span12" id="Hontact">
<h3><?php echo $page['heading'][0]; ?></h3>
<div class="subtext"><?php echo $page['subtext'][0]; ?></div>
<div class="content">
<a href="mailto:<?php echo $page['email'][0]; ?>"><?php echo $page['email'][0]; ?></a>
<div><?php echo $page['phone'][0]; ?></div>
<div><?php echo $page['address'][0]; ?></div>
</div>
</section>
I also added a few variables and styles to _elements.scss
@import url('https://fonts.googleapis.com/css?family=Lato|Lora:700i|Work+Sans:800');
$header-gray: #5d6771;
$subtext-blue: #5ac3b6;
html {
box-sizing: border-box;
}
*,
*:before,
*:after { /* Inherit box-sizing to make it easier to change the property for components that leverage other behavior; see http://css-tricks.com/inheriting-box-sizing-probably-slightly-better-best-practice/ */
box-sizing: inherit;
}
body {
background: $color__background-body; /* Fallback for when there is no custom background color defined. */
}
blockquote, q {
quotes: "" "";
&:before,
&:after {
content: "";
}
}
hr {
background-color: $color__background-hr;
border: 0;
height: 1px;
margin-bottom: 1.5em;
}
@import "lists";
img {
height: auto; /* Make sure images are scaled correctly. */
max-width: 100%; /* Adhere to container width. */
}
figure {
margin: 1em 0; /* Extra wide images within figure tags don't overflow the content area. */
}
.container {
width: 100%;
}
h1 {
color: $header-gray;
font: 800 51px/52px Work Sans, sans-serif;
font-weight: 900;
}
.subtext {
color: $subtext-blue;
font: italic bold 21px/25px 'Lora', serif;
}
@import "tables";
Thanks!
Jill