Wordpress: Load page content into custom template/theme - wordpress

I have created a custom theme from the scratch using Starkster to get a static wordpress version without posts/comments. Also, I added six pages in Wordpress with some words for content.
So, the design is working up to now, but I just can not get the content of those pages loaded into the website/browser. One DIV is opened in header.php and closed in footer.php and I thought, the content gets loaded in between.
That is what used up to now:
index.php:
<?php get_header(); ?>
<?php get_footer(); ?>
page.php:
<?php get_header(); ?>
<?php the_content(); ?>
<?php get_footer(); ?>
header.php:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title><?php bloginfo( 'name' ); ?><?php wp_title( '|' ); ?></title>
<meta charset="<?php bloginfo( 'charset' ); ?>" />
<meta name="viewport" content="width=device-width, initial-scale=1.0"><!-- REmove if you're not building a responsive site. (But then why would you do such a thing?) -->
<link rel="pingback" href="<?php bloginfo( 'pingback_url' ); ?>" />
<link rel="shortcut icon" href="<?php echo get_stylesheet_directory_uri(); ?>/img/favicon.ico"/>
<?php wp_head(); ?>
</head>
<body <?php body_class(); ?>>
<div id="oben"></div>
<div id="naviwrap">
<div id="titel"><h1 class="titelbutton">Coach</h1></div>
<div id="navigation">
<a class="navibutton" href="/" title="START">START</a>
<a class="navibutton" href="/coaching/" title="COACHING">COACHING</a>
<a class="navibutton" href="/termine/" title="TERMINE">TERMINE</a>
<a class="navibutton" href="/person/" title="PERSON">PERSON</a>
<a class="navibutton" href="/kontakt/" title="KONTAKT">KONTAKT</a>
<a class="navibutton" href="/impressum/" title="IMPRESSUM">IMPRESSUM</a>
</div>
</div>
<div class="clearer"></div>
<div id="wrap" class="inhaltverlauf">
<div id="blocker"></div>
<div id="inhalt">
footer.php:
</div>
<div class="clearer"></div>
</div>
<div id="farbhintergrund" class="farbverlauf"></div>
<?php wp_footer(); ?>
</body>
</html>
You can have a look over here: studio-scs.de
Elias helped me a great deal, but there is one other question that remains. With
page.php
<?php get_header(); ?>
<?php if (have_posts()) : while (have_posts()) : the_post();?>
<?php the_content(); ?>
<?php endwhile; endif; ?>
<?php get_footer(); ?>
I have removed all the posts as I wanted to, but if I now want to have the post ability back on just one of those pages (for instance Termine) to have the possibility to add new dates and so on, how can I do that?

You cannot use the_content without a query.
Replace your line the_content() with the following:
<div id="content" class="widecolumn">
<?php if (have_posts()) : while (have_posts()) : the_post();?>
<h2 id="post-<?php the_ID(); ?>"><?php the_title();?></h2>
<?php the_content(); ?>
<?php endwhile; endif; ?>
<?php edit_post_link('Edit this entry.', '<p>', '</p>'); ?>
</div>

Related

Wordpress archive and container error?

My single.php, archive, index and category.php pages are all the same using this coding below...
<?php
/*
Template Name: Lisa-beauty.co.uk
*/
?>
<?php get_header(); ?>
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<div class="headpostedin"><?php the_time('l, F jS, Y') ?> </div>
<div class="content" id="post-<?php the_ID(); ?>">" rel="bookmark" title="<?php the_title_attribute(); ?>"><div class="headtitle"><?php the_title(); ?></div>
<div class="postmetadata"></div>
<?php the_content(__('CONTINUE READING...')); ?>
<?php the_tags('Tags: ', ', ', '
'); ?>
<div class="headposted"><?php comments_popup_link('0', '1', '%'); ?> comments</div>
<?php echo DISPLAY_ULTIMATE_PLUS(); ?>
<?php comments_template(); // Get wp-comments.php template ?>
<?php endwhile; else: ?>
<?php _e('Sorry, no posts matched your criteria.'); ?>
<?php endif; ?>
</div>
<?php get_sidebar(); ?>
<?php get_footer(); ?>
Everyone works fine on my whole website lisa-beauty.co.uk but as soon as I click my archives in my sidebar then on to a page http://lisa-beauty.co.uk/lisa-beauty/?m=201509&paged=4 my whole container and sidebar are completely off but on other pages they are ok in my archive.
What could be causing the issue?
here is my coding from my header.php and footer.php
<!DOCTYPE html>
<head>
<meta name="description" content="Beauty uk blogger">
<meta name="keywords" content="blogger, beauty, fashion, make up">
<meta name="author" content="Lisa Robinson">
<meta charset="UTF-8">
<title>Lisa's Beauty UK Blog!</title>
<style type="text/css" media="screen"> #import url(/wp-content/themes/twentytwelve1/style.css);</style>
<?php wp_head(); ?>
</head>
<body>
<a name="top"></a>
<div id="container">
<div id="header" onclick="window.location='http://lisa-beauty.co.uk'">
</div>
<div id="content">
<div class="content">
</br>
</div>
footer
<div id="foot">
<div id="footer-wrapper">
</div>
</div>
<div class="top">
<u>↑ up</u>
</div>
<div class="left">
<div class="copyright">
Copyright 2015 www.lisa-beauty.co.uk <u>All rights reserved</u> | Powered by Wordpress | Theme by <u>Akaleez</u>
</div>
</div>
<?php get_sidebar(); ?>
<?php wp_footer(); ?>
</body>
</html>
This is most likely being caused by a rogue closing div somewhere. However, as sticksu says it's very difficult to debug this code.
Some general pointers:
1) Indent your code
It's far easier to debug this
<?php get_header(); ?>
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<div class="headpostedin">
<?php the_time('l, F jS, Y') ?>
</div>
<div class="content" id="post-<?php the_ID(); ?>" rel="bookmark" title="<?php the_title_attribute(); ?>">
<div class="headtitle">
<?php the_title(); ?>
</div>
<div class="postmetadata">
</div>
<?php the_content(__('CONTINUE READING...')); ?>
<?php the_tags('Tags: ', ', ', ''); ?>
<div class="headposted">
<?php comments_popup_link('0', '1', '%'); ?> comments
</div>
<?php echo DISPLAY_ULTIMATE_PLUS(); ?>
<?php comments_template(); // Get wp-comments.php template ?>
</div>
<?php endwhile; else: ?>
<?php _e('Sorry, no posts matched your criteria.'); ?>
<?php endif; ?>
<?php get_sidebar(); ?>
<?php get_footer(); ?>
than what you've posted above.
2. If you're using <br /> tags they should be like that rather than </br>
3. Validate your code.
If you're ever having layout issues like this, run your code through the W3C validator and 99% of the time it will give you some great clues as to the underlying issue.
I think the main issue is with this line:
<div class="content" id="post-<?php the_ID(); ?>">" rel="bookmark" title="<?php the_title_attribute(); ?>">
as you have an extra quote and close bracket in there. Try this instead:
<div class="content" id="post-<?php the_ID(); ?>" rel="bookmark" title="<?php the_title_attribute(); ?>">
Also note in the example above I've moved that final closing </div> at the bottom to be inside the loop, as it's good practice to close a div at the same level as abstraction as when you open it (the reason being that if there were no results returned the opening div would not be returned but the closing div would have been returned regardless, which would have then broken the page).

Wordpress post not displaying

header.php - file
I'am new to Wordpress scripting, can't figure out what i've done wrong? My post are not displaying
<nav class="subnav">
<?php wp_nav_menu(array('theme_location' => 'menu')); ?>
</nav>
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<article>
<div id="overview" class="tab">
<p><?php the_content(); ?></p>
</div>
</article>
<?php endwhile;?>
<?php endif; ?>
In header.php you should add something like this.
<!DOCTYPE html>
<html <?php language_attributes(); ?>>
<head>
<?php wp_head(); ?>
</head>
<nav class="subnav">
<?php wp_nav_menu(array('theme_location' => 'menu')); ?>
</nav>
In your front-page.php or home.php or index.php** include header.php with a wordpress specific function get_header() then render your menu, posts etc like this:
<?php
get_header();
if (have_posts()) : while (have_posts()) : the_post(); ?>
<article>
<div id="overview" class="tab">
<p><?php the_content(); ?></p>
</div>
</article>
<?php endwhile;?>
<?php endif; ?>
Please refer this
** If you are confused which php file to use please study WordPress hierarchy
Header.php
<!DOCTYPE html>
<html <?php language_attributes(); ?>>
<head>
<?php wp_head(); ?>
</head>
<body <?php body_class(); ?>>
<div id="page" class="hfeed site">
<header>
<nav class="subnav">
<?php wp_nav_menu(array('theme_location' => 'menu')); ?>
</nav>
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<article>
<div id="overview" class="tab">
<p><?php the_content(); ?></p>
</div>
</article>
<?php endwhile;?>
<?php endif; ?>
</header><!-- #masthead -->
<div id="content" class="site-content">
Output:
You can write your code on page.php or post.php otherwise you can create template and put below code and assign page to this template.
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<article>
<div id="overview" class="tab">
<p><?php the_content(); ?></p>
</div>
</article>
<?php endwhile;?>
<?php endif; ?>

Wordpress menu not displaying all menu item on some pages

I have searched for a while and cannot find anything specific to my issue.
I have a WordPress site that I added a new menu item, it does not display on some pages and others it does.
here is the site:
http://www.allproplumbers.com/
the 4th menu item under Plumbing should be Water Heater Brands as it is on the Plumbing page.
I don't get it, its the same menu or should be on ALL pages.
Even inspecting the element doesnt show it.
Sorry if this post doesn't contain enough information, i just don't know what else to post in it.
I don't have any cache plugins, I use the Swell Template (and yes, I checked there) but everything is about making it show the menu on certain pages, I need ALL menu items on ALL pages.
If there is something else I can post to clear this issue, I will post it.
as requested, header and footer code:
header.php
<!DOCTYPE html>
<html lang="en">
<head>
<title><?php wp_title(' » ', true); ?></title>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="shortcut icon" href="<?php echo_theme_dir('parent') ?>/favicon.png" />
<meta name="google-site-verification" content="sdUWtQY93zlQ0vEZ-gkNKX9ZAMRop4uUuMiR5v3ar6Y" />
<?php
wp_register_style( 'slbase', get_theme_dir('parent') . "/css/base.css" );
wp_enqueue_style( 'slbase' );
?>
<?php
wp_register_style( 'sldefault', get_theme_dir('parent') . "/css/default.css" );
wp_enqueue_style( 'sldefault' );
?>
<?php
wp_register_style( 'style', get_theme_dir('parent') . "/style.css" );
wp_enqueue_style( 'style' );
?>
<?php
wp_register_style( 'cstyle', get_theme_dir('parent') . "/custom.css" );
wp_enqueue_style( 'cstyle' );
?>
<?php wp_head(); ?>
<?php load_google_font('Asap:400,700'); ?>
<?php load_google_font('Droid+Sans'); ?>
<?php include_once(get_template_directory().'/inc/options.php'); ?>
</head>
<body <?php body_class(); ?>>
<header id="header" class="row">
<div class="container">
<div class="logo left">
<?php if($swell_opt['logo'] == null): ?>
<div id="logo"><?php bloginfo('name'); ?></div>
<h3 id="tagline" class="alt"><?php bloginfo('description'); ?></h3>
<?php else: ?>
<a title="<?php bloginfo('name'); ?>" href="<?php echo (site_url()); ?>"><img src="<?php echo $swell_opt['logo']; ?>" alt=""/></a>
<?php endif; ?>
</div>
<?php if($swell_opt['call_us_banner'] !== ''): ?>
<?php echo $swell_opt['call_us_banner']; ?>
<?php endif; ?>
</div>
</header>
<nav id="nav" class="row">
<div class="container">
<?php get_template_part('parts/mobile-menu'); ?>
<?php get_template_part('parts/top-bar'); ?>
<img src="<?php echo get_theme_dir('parent'); ?>/images/request-callback.png" alt=""/>
</div>
</nav>
<?php if(is_page('home')):?>
<div class="slider-container">
<?php echo do_shortcode('[rev_slider home-slider]'); ?>
</div>
<?php endif; ?>
<div class="clearfix"></div>
footer.php
<?php global $swell_opt; ?>
<footer id="footer" class="footer-container">
<div class="row footer-top">
<div class="container common">
<div class="col-3-12">
<?php wp_nav_menu( array('menu' => 'Footer', 'menu-class' => '') ); ?>
</div>
<div class="col-3-12">
<?php wp_nav_menu( array('menu' => 'Footer Right', 'menu-class' => '') ); ?>
</div>
<div class="col-6-12" id="contact-us">
<?php echo do_shortcode('[contact-form-7 id="64" title="Footer Form"]'); ?>
</div>
</div>
</div>
<div class="row footer-bottom">
<div class="container common copyright">
<div class="credit">
<img src="<?php echo get_theme_dir('parent'); ?>/images/bbb.png" alt=""/>
</div>
<ul class="social-media">
<?php if($swell_opt['facebook'] !== ''): ?>
<li></li>
<?php endif; ?>
<?php if($swell_opt['twitter'] !== ''): ?>
<li></li>
<?php endif; ?>
<?php if($swell_opt['google_plus'] !== ''): ?>
<li></li>
<?php endif; ?>
</ul>
<p>All Pro Plumbing Services 5075 E Airport Drive Ontario CA 91761</p>
<br>
<?php echo $swell_opt['copyright']; ?>
</div>
</div>
</footer>
<div id="requestcallback-hide" class="white-popup mfp-hide">
<?php echo do_shortcode('[contact-form-7 id="410" title="Request a Callback"]'); ?>
</div>
<div id="requestqoute-hide" class="white-popup mfp-hide">
<?php echo do_shortcode('[contact-form-7 id="411" title="Request a Quote"]'); ?>
</div>
<div id="schedule-service-form" class="white-popup-large mfp-hide">
<h2 class="center">Schedule a Service</h2>
<iframe src="http://www.allproplumbers.com/request-free-estimate.htm" width="100%" height="1250" frameborder="0"></iframe>
<!--<script type="text/javascript" src="http://form.jotform.us/jsform/xxxxxxxxxxxx"></script>-->
</div>
<?php
// load scripts
wp_deregister_script('jquery');
wp_enqueue_script('jquery', 'http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js', false, false, true);
?>
<?php wp_enqueue_script( 'slcommon', get_theme_dir('parent') . '/js/common.js', array('jquery'), false, true ); ?>
<?php wp_footer(); ?>
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-xxxxxxxx-1', 'auto');
ga('send', 'pageview');
</script>
<!-- Google Code for Website Form Conversion Page -->
<script type="text/javascript">
/* <![CDATA[ */
var google_conversion_id = xxxxxxxx;
var google_conversion_language = "en";
var google_conversion_format = "3";
var google_conversion_color = "ffffff";
var google_conversion_label = "wUWSCNvBvF4Q1eDr4AM";
var google_remarketing_only = false;
/* ]]> */
</script>
<script type="text/javascript" src="//www.googleadservices.com/pagead/conversion.js">
</script>
<noscript>
<div style="display:inline;">
<img height="1" width="1" style="border-style:none;" alt="" src="//www.googleadservices.com/pagead/conversion/xxxxxxxxx/?label=wUWSCNvBvF4Q1eDr4AM&guid=ON&script=0"/>
</div>
</noscript>
</body>
I am editing once again because the site asked me not to comment too much but turn it into chat, but i dont have privs to chat.
So i had a friend in another state load the site, it showed up where it was supposed to, however, he refreshed the page, now its gone.
Which immediately made me think of cookies, but like i said before, there are no cache plugins on the site, could there be a cookie plugin or something that i cant see? #ham-sandwich if you refresh the home page now that it is in your cache, does it still show?

can't get wp-pagenavi to work on a custom page on my wordpress site

I am using wp_pagenavi and i works fantastic on the homepage but on any of the custom pages it will show it has many pages but when i click next or page two the url changes like it should but nothing else change.
Below is the wordpress page template that i am using for all the custom pages.
<?php
/*
Template Name: Pages
*/
?>
<?php get_header(); ?>
<?php get_header(); ?>
<div class="home fix">
<div class="main">
<div class="fix">
<?php query_posts('category_name='.get_the_title().'&post_status=publish');?>
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<div class="post" id="post-<?php the_ID(); ?>">
<!-- thumbnail wrapper -->
<div class="thumb main">
<!-- 235150image-covers -->
<?php $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'single-post-thumbnail' ); ?>
<img src="<?php echo $image[0]; ?>" alt="" height="150" width="235"/>
<!-- 235150image end -->
<!-- thumbanil title -->
<div class="thumb-title">
<h2><a href="<?php the_permalink() ?>" title="<?php the_title(); ?>">
<?php the_title() ?>
<?php comments_number('{0}', '{1}', '{%}' );?>
</a></h2>
</div>
<!-- thumbanil title end -->
</div>
</div>
<?php endwhile; ?>
<?php else : ?>
<div class="post single">
<h2>No matching results</h2>
<div class="entry">
<p>You seem to have found a mis-linked page or search query with no associated or related results.</p>
</div>
</div>
<?php endif; ?>
<!-- adsense -->
<!-- adsense end -->
<!-- page navi -->
<div class="pagenavi">
<?php if(function_exists('wp_pagenavi')) { wp_pagenavi('', '', '', '', 4, false);}
$wp_query = null; $wp_query = $temp; ?>
</div>
<!-- page navi end -->
</div>
</div>
<div class="sidebarwrapper">
<?php include (TEMPLATEPATH . '/left.php'); ?>
<?php include (TEMPLATEPATH . '/right.php'); ?>
</div>
</div>
<?php include (TEMPLATEPATH . '/ancillary.php'); ?>
<?php get_footer(); ?>
Here I see you have use get_header() function two time.

The wordpress loop doesn't return the post structure

I just installed the latest Wordpress build (3.5.1) and when I add the loop as usual it doesn't return the normal structure.
This is my php:
<?php get_header(); ?>
<?php
$pageid = get_query_var('page_id');
$postid = $post->ID;
?>
<?php if(have_posts()) : ?><?php while(have_posts()) : the_post(); ?>
<div class="wppost" id="post-<?php the_ID(); ?>">
<h1><?php the_title(); ?></h1>
<div class="wpentry"><?php the_content(); ?></div>
</div>
<?php endwhile; ?>
<div class="wpnavigation">
<?php posts_nav_link('','Föregående sida','Nästa sida'); ?>
</div>
<?php else : ?>
<div class="wppost" id="post-<?php the_ID(); ?>">
<h1><?php _e('Inlägget hittades inte'); ?></h1>
</div>
<?php endif; ?>
And that usually works. But all it does now is return only what's in < p >-elements.
It doesn't return wppost, the_title, wpentry or anything except what I have written in the post itself (only text so far).
Is this something new or what am I doing wrong? I've done exactly this for a few years and it's worked so far. I'm stumped.
This is from the header.php:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head profile="http://gmpg.org/xfn/11">
<title><?php bloginfo('name'); ?><?php wp_title(); ?></title>
<meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php bloginfo('charset'); ?>" />
<meta name="generator" content="WordPress <?php bloginfo('version'); ?>" /> <!-- leave this for stats please -->
<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'); ?>" />
<?php wp_get_archives('type=monthly&format=link'); ?>
<?php //comments_popup_script(); // off by default ?>
<?php wp_head(); ?>
</head>
<body>
<div id="container">
<div id="maincontainer">
<div id="header">
<img alt="Descending Chaos" src="<?php bloginfo('template_directory'); ?>/images/liveheader.png" />
</div>
<div id="top">
<div id="menu">
<ul>
<?php wp_list_pages('title_li=','sort_column=menu_order'); ?>
</ul>
</div>
<div id="social">
<ul>
<li><img alt="Descending Chaos on Spotify" src="<?php bloginfo('template_directory'); ?>/images/spotlogo.png" /></li>
<li><img alt="Descending Chaos on Reverbnation" src="<?php bloginfo('template_directory'); ?>/images/reverblogo.png" /></li>
<li><img alt="Descending Chaos on Facebook" src="<?php bloginfo('template_directory'); ?>/images/facelogo.png" /></li>
<li><img alt="Descending Chaos on YouTube" src="<?php bloginfo('template_directory'); ?>/images/youlogo.png" /></li>
</ul>
</div>
</div>
EDIT: Updated the original post with more code.
If you run <?php print_r( $post ); ?> before the loop, you should be able to see the query. If it doesn't return anything, then there's a problem with the query. The code you've got here looks fine.
I added your code to my development site and it works there, so I don't think it is a problem with your code.
Try putting <?php wp_reset_query(); ?> before the loop. Maybe $wp_query and global post data got modifed before your loop and needs to be restored.

Resources