阿里云服务器

今天给大家介绍wordpress自定义文章类型的调用方法,只需要新增分类页archive-product.php 和文章页single-product.php

如果要在模板页面调用自定义文章类型的分类文章列表就需要用到以下代码;

<?php query_posts('post_type=product&showposts=6'); ?>
<?php while (have_posts()) : the_post(); ?> 
    <div class="col-sm-3 col-md-2 col-mm-6 product_img">
        <a href="<?php the_permalink() ?>">
<?php if ( has_post_thumbnail() ) { ?>
<?php the_post_thumbnail(array(270,270)); ?>
<?php } else {?>
<img src="<?php bloginfo('template_url'); ?>/images/554838fc3e9f9.jpg" />
<?php } ?>
        </a>
 <p class="product_title"><a href="<?php the_permalink() ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a></p>
    </div>
<?php endwhile; ?> 

 

通过上面代码就可以自定义在模板中调用自定义文章类型文章。

下面一篇给大家介绍一下增加wordpress自定义文章类型字段的方法。

相关阅读:
  • wordpress自定义文章类型置顶文章显示
  • wordpress自定义文章类型功能添加
  • 修改wordpress自定义文章类型固定连接的方法