I am building a single page theme, And I am having a problem with get_post_meta()
The Problem
This code bellow does not work, and I cannot see anything on the website as it's blank. Here is my index.php
.
<?php get_header(); ?>
<?php
global $query_string, $post;
query_posts($query_string . "post_type=page&post_status=publish&posts_per_page=9");
if ( have_posts() ) : while ( have_posts() ) : the_post();
$home = get_post_meta($post->ID, 'home', true);
$about = get_post_meta($post->ID, 'about', true);
$contact = get_post_meta($post->ID, 'contact', true);
$services = get_post_meta($post->ID, 'services', true);
?>
<?php if ( $home ) : ?>
<div id="home" class="borderline">
<?php the_content(); ?>
</div>
<?php endif; ?>
<?php if ( $about ) : ?>
<section class="about-us" id="about-us">
<div class="container">
<div class="row">
<div class="col-md-12">
<?php the_content(); ?>
</div>
</div>
</div>
</section>
<?php endif; ?>
<?php endwhile; endif; ?>
<?php get_footer(); ?>
The code above does not display anything.
Question
- How can I display my content using the code above?
- Guidance on developing single page themes, going forward?
- What page template hierarchy should I put my code?
My Pages look like this
Thank you in advance.
'Ace'
WP_Query()
? wordpress.stackexchange.com/questions/1753/…