0

我遇到的问题是我无法让 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)
 ?>
4

2 回答 2

1

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

于 2012-05-31T14:59:00.077 回答
0

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

我们需要知道您正在使用什么主题才能为您提供帮助。为了帮助自己,请通过检查您的主题文档文件或主题开发人员或该主题的任何帮助论坛来研究如何激活博客。

于 2012-05-31T14:57:41.137 回答