Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Code from functions.php
- add_action("init", "faqs_register");
- function faqs_register() {
- $labels = array(
- 'name' => _x('FAQs', 'post type general name'),
- 'singular_name' => _x('FAQ Item', 'post type singular name'),
- 'add_new' => _x('Add New', 'FAQ item'),
- 'add_new_item' => __('Add New FAQ'),
- 'edit_item' => __('Edit FAQ'),
- 'new_item' => __('New FAQ'),
- 'view_item' => __('View FAQ'),
- 'search_items' => __('Search FAQ'),
- 'not_found' => __('Nothing found'),
- 'not_found_in_trash' => __('Nothing found in Trash'),
- 'parent_item_colon' => ''
- );
- $args = array(
- 'labels' => $labels,
- 'public' => true,
- 'publicly_queryable' => true,
- 'show_ui' => true,
- 'query_var' => true,
- 'menu_icon' => get_stylesheet_directory_uri() . '/icons/faqs.png',
- 'rewrite' => array('slug' => 'faqs'),
- 'capability_type' => 'post',
- 'hierarchical' => false,
- 'menu_position' => 4,
- 'supports' => array('title','editor','thumbnail')
- );
- register_post_type( 'faq' , $args );
- flush_rewrite_rules();
- }
- //And code from page template
- <?php
- //http://codex.wordpress.org/Pages#A_Page_of_Posts_for_a_Custom_Post_Type
- /**
- * Template Name: Page of Articles
- **/
- ?>
- <?php get_header(); ?>
- <div id="container">
- <div id="content">
- <?php
- $type = 'faq';
- $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
- $args=array(
- 'post_type' => $type,
- 'post_status' => 'publish',
- 'paged' => $paged,
- 'posts_per_page' => 2,
- 'caller_get_posts'=> 1
- );
- //echo "<p>page: ".$paged."</p>";
- $temp = $wp_query; // assign orginal query to temp variable for later use
- $wp_query = null;
- $wp_query = new WP_Query($args);
- $wp_query->query($args);
- ?>
- <?php get_template_part( 'loop', 'index' );?>
- </div><!-- #content -->
- </div><!-- #container -->
- <?php get_sidebar(); ?>
- <?php get_footer(); ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement