View difference between Paste ID: aTMe4MqQ and hdZKU0kK
SHOW: | | - or go back to the newest paste.
1
functions.php
2
--------------
3
4
function create_post_type() {
5
 
6
 register_post_type( 'all_course',
7
     array(
8
        'labels' => array(
9
        'name' => __( 'Our Course' ),
10
        'singular_name' => __( 'course' ),
11
        'add_new' => __( 'Add New Course' ),
12
        'add_new_item' => __( 'Add New Course' ),
13
        'edit_item' => __( 'Edit Course' ),
14
        'new_item' => __( 'New Course' ),
15
        'view_item' => __( 'View Course' ),
16
        'not_found' => __( 'Sorry, we could not find the Course you are looking for.' )
17
      ),
18
    'public' => true,
19
    'publicly_queryable' => false,
20
    'exclude_from_search' => true,
21
    'menu_position' => 14,
22
    'has_archive' => false,
23
    'hierarchical' => false, 
24
    'capability_type' => 'page',
25
    'rewrite' => array( 'slug' => 'course' ),
26
    'supports' => array( 'title','thumbnail','editor','excerpt')
27
    // all supports options  'title', 'editor', 'author', 'thumbnail', 'excerpt', 'comments','trackbacks','custom-fields','revisions','page-attributes','post-formats'
28
    )
29
  );
30
}
31
32
33
add_action( 'init', 'create_post_type' );
34
35
36
37
38
39
index.php
40
=========
41
42
43
                <?php if(!is_paged()) { ?>
44
                 <?php
45
                    $args = array( 'post_type' => 'all_course', 'posts_per_page' => 8 );
46
                    $loop = new WP_Query( $args );
47
                 ?>  
48
                 <?php while ( $loop->have_posts() ) : $loop->the_post(); ?>         
49
                <div class="col-md-3 col-sm-4 col-xs-12">
50
                    <div id="course_animate_1" class="single-featured">
51
                        <ul class="list-unstyled featured-list">
52
                            <li>
53
                               <?php the_post_thumbnail('image_of_course', array('class' => 'postthumbnails')); ?>
54
                            </li>
55
                            <li>
56
                                <h2><?php the_title(); ?></h2>
57
                            </li>
58
                        </ul> 
59
                            <?php the_excerpt(); ?>
60
61
                        <div class="feature-title">
62
                            <a href="<?php the_permalink(); ?>">Learn More</a>
63
                            <ul class="list-unstyled list-inline pull-right">
64
                                <li><a href="<?php the_permalink(); ?>"><i class="fa fa-chevron-right"></i></a>
65
                                </li>
66
                            </ul>
67
                        </div>
68
                    </div>
69
                </div>
70
71
                 <?php endwhile; ?>
72
                 <?php wp_reset_query(); ?>
73
                 <?php } ?>