Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Add this code to your functions.php
- add_action( 'init', 'create_post_type' );
- function create_post_type() {
- register_post_type( 'products',
- array(
- 'labels' => array(
- 'name' => __( 'Products' ),
- 'singular_name' => __( 'Products' )),
- 'public' => true,
- 'has_archive' => true,
- 'rewrite' => array('slug' => 'products')
- )
- );
- }
- // Add this code in your template file
- <?php
- /**
- * Template Name: Products
- * Description: Product template
- *
- * @package Waipoua
- * @since Waipoua 1.0
- */
- get_header(); ?>
- // The loop for your custom post Types
- <ul class="products">
- <?php $args = array( 'post_type' => 'products', 'posts_per_page' => 30, 'orderby' => 'rand' );
- $loop = new WP_Query( $args );
- while ( $loop->have_posts() ) : $loop->the_post();
- echo '<li>';
- the_title('<h3>', '</h3>');
- the_content();
- echo '</li>';
- endwhile; ?>
- </ul>
Add Comment
Please, Sign In to add comment