wordpress不会显示帖子

时间:2012-05-31 14:52:16

标签: wordpress

我遇到的问题是我无法让Wordpress显示我需要的帖子。

我已经尝试在阅读设置中使用两种方法,方法是选择一个页面来显示不起作用的帖子。第二个是一个getpost插件,使用短代码显示帖子[get_posts]它没有显示任何帖子只是短代码并且插件是活动的。

我希望它显示为http://www.completesource.co.uk/category/ironkey-id-theft/,但在此页http://beta.completesource.co.uk/it-news/

我一直在寻找这一点,任何帮助将不胜感激。

谢谢

编辑:代码

<?php
if (is_page() ) {
$category = get_post_meta($posts[0]->ID, 'category', true);
}
if ($category) {
$cat = get_cat_ID($category);
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$post_per_page = -1; // -1 shows all posts
$do_not_show_stickies = 1; // 0 to show stickies
$args=array(
'category__in' => array($cat),
'orderby' => 'date',
'order' => 'DESC',
'paged' => $paged,
'posts_per_page' => $post_per_page,
'caller_get_posts' => $do_not_show_stickies
);
$temp = $wp_query;  // assign orginal query to temp variable for later use   
$wp_query = null;
$wp_query = new WP_Query($args); 
if( have_posts() ) : 
    while ($wp_query->have_posts()) : $wp_query->the_post(); ?>
    <div <?php post_class() ?> id="post-<?php the_ID(); ?>">
    <h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?     php the_title_attribute(); ?>"><?php the_title(); ?></a></h2>
    <small><?php the_time('F jS, Y') ?> <!-- by <?php the_author() ?> --></small>
    <div class="entry">
      <?php the_excerpt('Read the rest of this entry »'); ?>
     <a href="<?php the_permalink() ?>">Read More..</a>
     <BR><BR>
    </div>

  </div>
<?php endwhile; ?>
<div class="navigation">
  <div class="alignleft"><?php next_posts_link('« Older Entries') ?></div>
  <div class="alignright"><?php previous_posts_link('Newer Entries »') ?></div>
</div>
 <?php else : ?>
    <h2 class="center">Not Found</h2>
<p class="center">Sorry, but you are looking for something that isn't here.</p>
    <?php get_search_form(); ?>
<?php endif; 
$wp_query = $temp;  //reset back to original query
  }  // if ($category)
 ?>

2 个答案:

答案 0 :(得分:1)

我个人会为页面编写页面模板,然后创建一个新页面并使用该模板。开始阅读Page Templates并从那里开始。

答案 1 :(得分:0)

市场上的每个Wordpress主题都会以非常不同的方式处理帖子的显示。它可以通过页面,短代码,模板,设置等。

我们需要知道您使用的主题是为了帮助您。为了帮助自己,请通过检查主题文档文件或主题开发人员或主题的任何帮助论坛来调查如何激活博客。

相关问题