开发者

display posts under specific page

开发者 https://www.devze.com 2023-01-27 19:48 出处:网络
I a开发者_Go百科m having many number of pages, I would like to display some specific posts under one specific page.

I a开发者_Go百科m having many number of pages, I would like to display some specific posts under one specific page. for example Under News page i need to display only news related posts only

how to do this?


This is a new query, won't effect the main Wordpress loop and can be used multiple times on a page. Change parameters to your category name and number of posts to show. Use in a page template or in page editor with php execution enabled.

<?php $my_query = new WP_Query('category_name=mycategory&showposts=1'); ?>

<?php while ($my_query->have_posts()) : $my_query->the_post(); ?>

<a href="<?php the_permalink() ?>" title="<?php the_title(); ?>">

<?php the_title(); ?></a>

<?php the_content(); ?>

<?php endwhile; ?>
0

精彩评论

暂无评论...
验证码 换一张
取 消