Wordpress archive and container error? - wordpress

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).

Related

<?php wp_link_pages(); ?> is working on posts but not on pages to display pagination

I created a theme from scratch and have pagination working on the post pages using , it's working on single.php.
<?php get_header(); ?>
<?php
while(have_posts()) {
the_post();
?>
<div class="mainConent">
<div class="leftSidebar">
<div class="sidebarTitleWrapper">
<?php dynamic_sidebar('left_sidebar') ?>
</div>
</div>
<div class="recentBlogsWrapper">
<div class="blogWrapper">
<h2><?php the_title(); ?></h2>
<p><?php the_time('F j, Y') ?></p>
<?php if(has_post_thumbnail()) { ?>
<div class="card-image">
<img class="page-image" src="<?php echo get_the_post_thumbnail_url(get_the_ID()); ?>" alt="Card Image">
</div>
<?php } ?>
<div class="card-description">
<?php the_content(); ?>
<?php wp_link_pages(); ?>
<?php comments_template(); ?>
<?php } ?>
<div class="backarrowwrap">
<a class="backhomelink" href="<?php echo site_url(); ?>" <?php if(is_front_page()) echo 'class="active"' ?>>
<img class="backarrow" src="<?php echo get_template_directory_uri(); ?>/img/backarrow.png" alt="back arrow" />
Go Back Home
</a>
</div>
</div>
</div>
</div>
<div class="rightSidebar" id="sidebar">
<div class="sidebarTitleWrapper">
<?php dynamic_sidebar('right_sidebar') ?>
</div>
</div>
I put it right below the_content(); and it's working exactly like I want it to. However, it's not working on page.php, even though it's in the same place on the page.
<?php get_header();
while(have_posts()) {
the_post();
?>
<div class="pageWrapper">
<h2><?php the_title(); ?></h2>
<?php if(has_post_thumbnail()) { ?>
<div class="card-image">
<img class="page-image" src="<?php echo get_the_post_thumbnail_url(get_the_ID()); ?>" alt="Card Image">
</div>
<?php } ?>
<div class="card-description">
<?php the_content(); ?>
<?php wp_link_pages(); ?>
<?php } ?>
</div>
</div>
<?php get_footer(); ?>
I've included the
<!–-nextpage-–>
code in one of my pages just like I did for the blogs, but it's not paginating between the paragraphs.
What am I doing wrong?
You need at least one <!--nextpage-->, if the content of a page (or post) has at least one <!--nextpage--> tag (and this code is in The Loop), this prints linked page numbers (“Pages: 1 2 3 4 and so on...”), without a link on current page number, and by default within tags:.

<! --nextpage--> pagination is not working in Wordpress

I'm trying to make it so posts can be easily paginated in a custom theme, but I'm doing something wrong. I've included wp_link_pages(); in the while like which I believe is required, but maybe I have it in the wrong place or I'm missing something else?
<?php get_header(); ?>
<?php
while(have_posts()) {
the_post();
wp_link_pages();
?>
<div class="mainConent">
<div class="leftSidebar">
<div class="sidebarTitleWrapper">
<?php dynamic_sidebar('left_sidebar') ?>
</div>
</div>
<div class="recentBlogsWrapper">
<div class="blogWrapper">
<h2><?php the_title(); ?></h2>
<p><?php the_time('F j, Y') ?></p>
<?php if(has_post_thumbnail()) { ?>
<div class="card-image">
<img class="page-image" src="<?php echo get_the_post_thumbnail_url(get_the_ID()); ?>" alt="Card Image">
</div>
<?php } ?>
<div class="card-description">
<?php the_content(); ?>
<?php comments_template(); ?>
<?php } ?>
<div class="backarrowwrap">
<a class="backhomelink" href="<?php echo site_url(); ?>" <?php if(is_front_page()) echo 'class="active"' ?>>
<img class="backarrow" src="<?php echo get_template_directory_uri(); ?>/img/backarrow.png" alt="back arrow" />
Go Back Home
</a>
</div>
</div>
</div>
</div>
<div class="rightSidebar" id="sidebar">
<div class="sidebarTitleWrapper">
<?php dynamic_sidebar('right_sidebar') ?>
</div>
</div>
<?php get_footer(); ?>
Another odd thing that's happening is that the code block is showing the code on the page instead of hiding it like it should.
The wordpress editor
My blog post page which shows the code
Gutenburg was preventing me from writing the comment as code, even in a code box. Once I switched to the classic view the problem went away since I could write the comment in the html directly.

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; ?>

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.

Is it possible to split "Custom Post Types" in WordPress?

Why does <!--nextpage--> work on pages, but not on Custom Post Types?
Here is the code of the single-custom_type.php file.. I added the "<?php wp_link_pages(); ?>" by myself. I hoped that would work, but it doesn't. There is nothing more to say actually.
<?php get_header(); ?>
<div id="content">
<div id="inner-content" class="wrap clearfix">
<div id="main" class="eightcol first clearfix" role="main">
<?php include(TEMPLATEPATH . '/template-logo.php'); ?>
<div class="content">
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<article id="post-<?php the_ID(); ?>" <?php post_class('clearfix'); ?> role="article">
<header class="article-header">
<h2 class="h2"><?php the_title(); ?></h2>
</header> <!-- end article header -->
<section class="entry-content clearfix">
<?php if ( function_exists("has_post_thumbnail") && has_post_thumbnail() ) { ?>
<a href="<?php the_permalink(); ?>" title="Permanent Link to <?php the_title(); ?>">
<?php the_post_thumbnail(array(200,200), array("class" => "alignleft post_thumbnail")); ?>
</a>
<?php } ?>
<?php the_content(); ?>
<?php wp_link_pages(); ?>
<hr>
</section> <!-- end article section -->
<footer class="article-footer">
<p class="tags"><?php the_tags('<span class="tags-title">Tags:</span> ', ', ', ''); ?></p>
</footer> <!-- end article footer -->
<?php // comments_template(); // uncomment if you want to use them ?>
</article> <!-- end article -->
<?php endwhile; ?>
<?php else : ?>
<article id="post-not-found" class="hentry clearfix">
<header class="article-header">
<h1><?php _e("Oops, Post Not Found!", "bonestheme"); ?></h1>
</header>
<section class="entry-content">
<p><?php _e("Uh Oh. Something is missing. Try double checking things.", "bonestheme"); ?></p>
</section>
<footer class="article-footer">
<p><?php _e("This is the error message in the single-custom_type.php template.", "bonestheme"); ?></p>
</footer>
</article>
<?php endif; ?>
[...]

Resources