0
无法解决此问题。我为我的wordpress主题设置了一个自定义模板,并试图将目前有类别链接和标题回显的位更改为帖子标题的回显。Wordpress在循环问题中回显the_title问题
目前反响:
echo '<h2><a href="'.$catLink.'" title="'.$category->name.'">'.$category->name.'</a></h2>';
谁能帮助吗?
整版代码:
<div id="older-posts">
<?php
// Get the current category
foreach((get_the_category()) as $category)
{
$current_cat_id = $category->cat_ID;
break;
}
// Set the category to only the category selected
$args = array(
'category__in' => array($current_cat_id),
'orderby' => 'date',
'order' => 'DESC'
);
$posts = new WP_Query();
$posts->query($args);
if ($posts->have_posts())
{
while ($posts->have_posts())
{
echo '<div class="result">';
echo '<h2><a href="'.$catLink.'" title="'.$category->name.'">'.$category->name.'</a></h2>';
$posts->the_post();
?>
<div class="thumbnail">
<a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title(); ?>">
<h3><?php the_title(); ?></h3>
<?php //get thumnbnail (custom field) ?>
<?php $image = get_post_meta($post->ID, 'thumbnail', true); ?>
<img src="<?php echo $image; ?>" title="<?php the_title(); ?>" />
<?php the_post_thumbnail(); ?>
</a>
</div> </div>
<?php
}
}
// Reset global query
wp_reset_query();
?>
</div>
完美。正如你所建议的在$ posts-> the_post();之后移动帖子标题和链接。诀窍。非常感谢! – Jac 2011-04-03 10:09:27
不客气! – 2011-04-04 02:58:00