我使用WordPress的keremiya主题。如果“most_viewed”选项打开,我试图在我的自定义文章类型中显示我查看次数最多的文章。我的自定义帖子类型的名称是watch。我怎样才能用我现在的代码做到这一点?我也使用名为wp-post views的插件来显示我侧边栏中的视图。这是我的查询。如何在自定义帖子类型中显示最多查看的帖子
<?php if(get_option('most_viewed') == 'On'): ?>
<div class="sidebar-right">
<h2><?php echo get_option('my_title'); ?></h2>
<div class="fimanaortala">
<?php $tavsayi = get_option('keremiya_tavsiyesayi'); $tavkat = get_option('keremiya_tavsiyekat');?>
<?php query_posts('showposts='.$tavsayi.'&v_orderby=desc&cat='.$tavkat.'') ?>
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<div class="filmana">
<div class="filmsol">
<?php keremiya_resim('80px', '70px', 'izlenen-resim'); ?>
</div>
<div class="filmsag">
<div class="filmsagbaslik">
<a href="<?php the_permalink() ?>"><?php the_title(); ?></a>
</div>
<div class="filmsagicerik">
<?php if(function_exists('the_views')) { the_views(); echo " "; } ?>
<p><?php nezaman_yazildi(); ?></p>
</div>
<div class="filmizleme">
<a href="<?php the_permalink() ?>"><img src="<?php bloginfo('template_directory'); ?>/images/filmizle.png" alt="film izle" height="21" width="61" /></a>
</div>
</div>
</div>
<?php endwhile; else: ?>
<?php endif; ?>
<?php wp_reset_query(); ?>
</div>
</div>
当我试图将此添加到我的边栏我收到死亡的白色屏幕。哈哈:D我完全失去了。我很新的php –
我的意思是它没有工作不是死亡的白色屏幕。 –
你应该把第一个两个方法放到'functions.php'文件中。第三个是wp_loop的一个非常原始的版本,它应该可以在你的边栏中正常工作。只要不要忘记'wp_reset_query();'在完成循环 –