gpt4 book ai didi

php - 如何在wordpress的三个不同列中查看三个不同类别的帖子?

转载 作者:行者123 更新时间:2023-11-29 06:56:14 25 4
gpt4 key购买 nike

我真的是“WordPress”的新手,目前面临的问题是我正在使用 FUNDA 主题,并尝试根据类别 ID 在三个不同的列中显示三个不同的帖子类别,但找不到特定的帖子类别。

我试试这个

<?php 
$data = cats_to_select();
$cat_id = $data[1][value];
global $cat_id;?>
<?php print_r($cat_id);?>

<?php if($cat_id==3):?>
<?php if (have_posts()) : ?>
<?php while (have_posts()) : the_post(); ?>
<div <?php post_class() ?> id="post-<?php the_ID(); ?>">
<?php if ( function_exists("has_post_thumbnail") && has_post_thumbnail() ) { the_post_thumbnail(array(260,200), array("class" => "alignleft post_thumbnail")); } ?>
<h2 class="title"><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2>
<div class="postdate"><img src="<?php bloginfo('template_url'); ?>/images/date.png" /> <?php the_time('F jS, Y') ?> <img src="<?php bloginfo('template_url'); ?>/images/user.png" /> <?php the_author() ?> <?php if (current_user_can('edit_post', $post->ID)) { ?> <img src="<?php bloginfo('template_url'); ?>/images/edit.png" /> <?php edit_post_link('Edit', '', ''); } ?></div>

<div class="entry">
<?php the_content('<strong>Read more &raquo;</strong>'); ?>
</div>
</div><!--/post-<?php the_ID(); ?>-->

<?php endwhile; ?>
<div class="navigation">
<?php if(function_exists('wp_pagenavi')) { wp_pagenavi(); } else { ?>
<div class="alignleft"><?php next_posts_link('&laquo; Older Entries') ?></div>
<div class="alignright"><?php previous_posts_link('Newer Entries &raquo;') ?></div>
<?php } ?>
</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; ?>
<?php endif; ?>

谁能帮帮我?提前致谢。

最佳答案

<?php query_posts('cat=3'); ?> // here, 3 will be replaced with desired
// category id, or you may add array
<?php if (have_posts()) : ?>
<?php while (have_posts()) : the_post(); ?>
<div <?php post_class() ?> id="post-<?php the_ID(); ?>">
<?php if ( function_exists("has_post_thumbnail") && has_post_thumbnail() ) { the_post_thumbnail(array(260,200), array("class" => "alignleft post_thumbnail")); } ?>
<h2 class="title"><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2>
<div class="postdate"><img src="<?php bloginfo('template_url'); ?>/images/date.png" /> <?php the_time('F jS, Y') ?> <img src="<?php bloginfo('template_url'); ?>/images/user.png" /> <?php the_author() ?> <?php if (current_user_can('edit_post', $post->ID)) { ?> <img src="<?php bloginfo('template_url'); ?>/images/edit.png" /> <?php edit_post_link('Edit', '', ''); } ?></div>

<div class="entry">
<?php the_content('<strong>Read more &raquo;</strong>'); ?>
</div>
</div><!--/post-<?php the_ID(); ?>-->

<?php endwhile; ?>

关于php - 如何在wordpress的三个不同列中查看三个不同类别的帖子?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12588789/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com