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; ?>
Related
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).
I'm developping a wordpress theme. I'm making a custom theme for a specific page.
I created a "Home" page with the identifier "home". I created a page-home.php file, with this loop:
<?php get_header();
get_topmenu(); ?>
<div class="catch"></div>
<div id="primary" class="content-area page-home">
<div id="content" class="site-content" role="main">
<?php /* The loop */ ?>
<?php if(have_posts()) : ?>
<?php while (have_posts()) : the_post(); ?>
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<h1 class="entry-title"><?php the_title(); ?></h1>
<div class="entry-content">
<?php the_content(); ?>
</div><!-- .entry-content -->
</article><!-- #post -->
<?php comments_template(); ?>
<?php endwhile; ?>
<?php endif; ?>
</div><!-- #content -->
</div><!-- #primary -->
PAGE HOME.PHP
<?php get_sidebar(); ?>
<?php get_footer(); ?>
But doing this, when I call ?q=home, I've got ALL my pages displayed in the loop, and not just the "home" page... What is the cleanest way to get just the "Home" page ?
I'm trying to have two things on a Wordpress page: a list of Custom Posts as well as the content of the custom posts. I would like the titles of the Custom Posts to link to the section of the page with the posts' content.
For example:
Item One
Item Two
Item Three
ITEM ONE HEADING
Item One content...
ITEM TWO HEADING
Item two content...
ITEM THREE HEADING
Item three content...
So "Item One" would link to "ITEM ONE HEADING". Here's the code I'm using which shows the Custom Post List as well as the content, but the list items link out to the Custom Post's page.
<ul>
<?php
$query = new WP_Query( array( 'post_type' => array( 'drilling' ) ) );
while ( $query->have_posts() ) : $query->the_post();
echo '<li><a href="';
the_permalink();
echo '">';
the_title();
echo '</a></li>';
endwhile;
?>
</ul>
<?php wp_reset_query(); ?>
and
<?php query_posts( 'post_type=drilling'); ?>
<?php if (have_posts()): while (have_posts()) : the_post(); ?>
<!-- article -->
<section class="service-middle">
<div class="container">
<div class="service-middle-content sixteen columns">
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<h2><?php echo get_the_title($ID); ?> </h2>
<?php the_content(); ?>
<br class="clear">
<?php edit_post_link(); ?>
</article>
<!-- /article -->
</div> <!--end service-middle-content-->
</div> <!--end container-->
</section> <!--end service-middle-->
<?php endwhile; ?>
<?php else: ?>
<!-- article -->
<article>
<h2><?php _e( 'Sorry, nothing to display.', 'html5blank' ); ?></h2>
</article>
<!-- /article -->
<?php endif; ?>
Thanks so much for any help!
-Dan
You want to use HTML Anchors
http://www.w3schools.com/html/html_links.asp
It is worth mentioning that you don't actually need to query the posts twice. You could you the WP get_posts function (https://codex.wordpress.org/Template_Tags/get_posts) to get the posts as an array and then loop through this array to generate a nav and your post contents.
Hope this helps!
<ul>
<?php
$query = new WP_Query( array( 'post_type' => array( 'drilling' ) ) );
while ( $query->have_posts() ) :
$query->the_post();
?>
<li><?php the_title(); ?></li>
<?php endwhile; ?>
</ul>
<?php wp_reset_query(); ?>
<?php query_posts( 'post_type=drilling'); ?>
<?php if (have_posts()): while (have_posts()) : the_post(); ?>
<!-- article -->
<section class="service-middle">
<div class="container">
<div class="service-middle-content sixteen columns">
<!-- Anchor Tag -->
<a name="post-<?php the_ID(); ?>"></a>
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<h2><?php echo the_title(); ?> </h2>
<?php the_content(); ?>
<br class="clear">
<?php edit_post_link(); ?>
</article>
<!-- /article -->
</div> <!--end service-middle-content-->
</div> <!--end container-->
</section> <!--end service-middle-->
<?php endwhile; ?>
<?php else: ?>
<!-- article -->
<article>
<h2><?php _e( 'Sorry, nothing to display.', 'html5blank' ); ?></h2>
</article>
<!-- /article -->
<?php endif; ?>
I want to add several images and divs and also customize the look of my Blog post listing... But i can't find the way to do it.
Here's the Blog Template code
<?php
/*
WARNING: This file is part of the core Genesis framework. DO NOT edit
this file under any circumstances. Please do all modifications
in the form of a child theme.
*/
/**
* Template Name: Blog
* This file handles blog post listings within a page.
*
* This file is a core Genesis file and should not be edited.
*
* The blog page loop logic is located in lib/structure/loops.php
*
* #category Genesis
* #package Templates
* #author StudioPress
* #license http://www.opensource.org/licenses/gpl-license.php GPL v2.0 (or later)
* #link http://www.studiopress.com/themes/genesis
*/
genesis();
and just above the genesis(); code.. i tried to put some divs and images there.. But i guess that's not the way it works. ..
I also tried to make my own Blog listing template using a normal wordpress code theme..
<?php /*
Template Name: List Post Pages
*/
?>
<?php get_header(); ?>
<?php if ( has_post_thumbnail() ) { ?>
<div class="featured">
<?php the_post_thumbnail(); ?>
</div>
<?php } ?>
<div class="divider"></div>
<div id="content" class="hfeed">
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<div <?php post_class() ?> id="post-<?php the_ID(); ?>">
<h2><a href="<?php the_permalink() ?>">
<?php the_title(); ?>
</a></h2>
<div class="entry">
<?php the_content(); ?>
</div>
<div class="postmetadata">
<?php the_tags('Tags: ', ', ', '<br />'); ?>
Posted in
<?php the_category(', ') ?>
|
<?php comments_popup_link('No Comments »', '1 Comment »', '% Comments »'); ?>
</div>
</div>
<?php endwhile; ?>
<?php else : ?>
<h2>Not Found</h2>
<?php endif; ?>
<?php genesis_after_loop(); ?>
</div>
<?php get_footer(); ?>
But no luck, what's the right way to do this?
***Update -code below is the one i want.. but instead of having the Content of the page. I want the list of Post with excerpts ....How can i do that????
<?php /*
Template Name: Page Template
*/ ?>
<?php get_header(); ?>
<?php if ( has_post_thumbnail() ) { ?>
<div class="featured">
<?php the_post_thumbnail(); ?>
</div>
<?php } ?>
<div class="divider"></div>
<?php genesis_before_content_sidebar_wrap(); ?>
<div id="content-sidebar-wrap">
<?php genesis_before_content(); ?>
<div id="content" class="hfeed">
<?php genesis_before_loop(); ?>
<?php genesis_loop(); ?>
<?php genesis_after_loop(); ?>
</div>
<!-- end #content -->
<?php genesis_after_content(); ?>
</div>
<!-- end #content-sidebar-wrap -->
<?php genesis_after_content_sidebar_wrap(); ?>
<?php get_footer(); ?>
Im shocked that no one answered my question.. anyway, if someone bumps onto this post with similar problem. The answer is adding
<?php query_posts( $args ); ?>
just above the <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
All in all, my code looks like this ...
<?php /*
Template Name: Page Template
*/ ?>
<?php get_header(); ?>
<?php if ( has_post_thumbnail() ) { ?>
<div class="featured">
<?php the_post_thumbnail(); ?>
</div>
<?php } ?>
<div class="divider"></div>
<?php genesis_before_content_sidebar_wrap(); ?>
<div id="content-sidebar-wrap">
<?php genesis_before_content(); ?>
<div id="content" class="hfeed">
<?php genesis_before_loop(); ?>
<?php query_posts( $args ); ?>
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<div <?php post_class() ?> id="post-<?php the_ID(); ?>">
<h2><a href="<?php the_permalink() ?>">
<?php the_title(); ?>
</a></h2>
<div class="entry">
<?php the_content(); ?>
</div>
<div class="postmetadata">
<?php the_tags('Tags: ', ', ', '<br />'); ?>
Posted in
<?php the_category(', ') ?>
|
<?php comments_popup_link('No Comments »', '1 Comment »', '% Comments »'); ?>
</div>
</div>
<?php endwhile; ?>
<?php else : ?>
<h2>Not Found</h2>
<?php endif; ?>
<?php genesis_after_loop(); ?>
</div>
<!-- end #content -->
<?php genesis_after_content(); ?>
</div>
<!-- end #content-sidebar-wrap -->
<?php genesis_after_content_sidebar_wrap(); ?>
<?php get_footer(); ?>
I am trying to include every post onto my index page on WordPress and have each one of them be styled with the included CSS. I am able to query all of the posts and have them show up, but only the first post is actually styled. The rest inherit the base h1, h2, p and other generic styles, but they aren't inheriting the "box" class for each one. All of the information is being thrown into one 'box' class instead of starting a new 'box' class for each post like I would like it to do. Any help on this would be appreciated.
Here is my code I am using
<?php get_header(); ?>
<div id="index-float-left">
<div class="box">
<?php query_posts( 'showposts=-1' ); ?>
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<div <?php post_class() ?> id="post-<?php the_ID(); ?>">
<h1><?php the_title(); ?></h1>
<p><?php the_content(); ?></p>
<p class="post-date"><?php echo $post_date = get_the_date(); ?></p>
</div>
</div> <!-- END BOX -->
</div> <!-- FLOAT BOX BOX -->
<?php endwhile; ?>
<?php else : ?>
<h2>Not Found</h2>
<?php endif; ?>
<?php get_sidebar(); ?>
<?php get_footer(); ?>
There is a problem with "End Box" and "Fload Box Box". Can you try like this:
<?php get_header(); ?>
<div id="index-float-left">
<?php query_posts( 'showposts=-1' ); ?>
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<div class="box">
<div <?php post_class() ?> id="post-<?php the_ID(); ?>">
<h1><?php the_title(); ?></h1>
<p><?php the_content(); ?></p>
<p class="post-date"><?php echo $post_date = get_the_date(); ?></p>
</div>
</div> <!-- END BOX -->
<?php endwhile; ?>
<?php else : ?>
<h2>Not Found</h2>
<?php endif; ?>
</div> <!-- FLOAT BOX BOX -->
<?php get_sidebar(); ?>