Could you post the code from your index.php file?
This is code in index.php. It doesn’t work.
get_header(); ?>
<div class=”spnoibat”></div>
<div class=”leftpanel”>
<?php include ‘sanpham.php’; ?>
</div>
<div id=”content” class=”site-content” role=”main”>
<?php /* The loop */ ?>
<?php
$arg = array(
‘post_type’ => ‘post’
);
$query = new $wp_query($arg);
while($query->have_posts()): $query->the_post();
?>
<div class=”loadcontent”>
<div class=”hinh”>“><?php echo the_post_thumbnail();?></div>
<div class=”info”>“><?php the_title(); ?>
<?php echo get_post_meta(get_the_ID(),’Giá’,true); ?></div>
</div>
<?php endwhile; ?>
</div><!– #content –>
And this is code in category.php. It work !
get_header(); ?>
<div class=”spnoibat”></div>
<div class=”menunav”>
<?php
//get id of current category
$id = get_query_var(‘cat’);
// get category parent
$nav = get_category_parents($id,true,'<span class=”navi”></span>’);?>
“>Trang chủ<span class=”navi”><?php echo $nav;?></span>
</div>
<div class=”leftpanel”>
<?php include ‘sanpham.php’; ?>
</div>
<div id=”content” class=”site-content” role=”main”>
<?php while ( have_posts() ) : the_post(); ?>
<div class=”loadcontent”>
<div class=”hinh”>“><?php the_post_thumbnail();?></div>
<div class=”info”>“><?php the_title(); ?>
<?php echo get_post_meta(get_the_ID(),’Giá’,true); ?></div>
</div>
<?php endwhile; ?>
</div><!– #content –>
My custom field: key: Giá value: 120000
I want to get value 120000 and display on index page.
Is anything showing from the loop on the index.php page?
I believe:
$query = new $wp_query($arg);
should be:
$query = new WP_Query($arg);