如何在主页中创建自定义帖子类型?

时间:2010-10-14 06:44:18

标签: wordpress-plugin wordpress-theming

我的网站上有自定义主页。我想添加3个自定义帖子来更新图像,文本和链接。如何在wordpress 3.1中完成?

1 个答案:

答案 0 :(得分:0)

在functions.php中创建自定义帖子类型。 How to make custom post type!然后为每个帖子类型添加自定义循环到静态主页模板,如下所示:

// The Query
   $args = array(
       'post_type' => 'YOUR POST TYPE',
       'posts_per_page' => 1 (Or as many or as few as you want -1 shows all!)
    );
    $the_query = new WP_Query( $args );

    // The Loop
    while ( $the_query->have_posts() ) : $the_query->the_post();
        echo '<li>';
        the_title();
        echo '</li>';
    endwhile;

    // Reset Post Data
    wp_reset_postdata();

    ?>