The best way to query this post type?
-
This is my custom post type – meant to show a small picture of an artist’s recent release, with a title and custom fields. How do I query it, if I want it as a custom loop in the sidebar? Can it be done with the get_posts function? Thanks in advance.
add_action( 'init', 'register_imnet_recentrelease' ); function register_imnet_recentrelease() { $labels = array( 'name' => _x( 'recent release', 'recent release' ), 'singular_name' => _x( 'recent release', 'recent release' ), 'add_new' => _x( 'Add New', 'recent release' ), 'add_new_item' => _x( 'Add New recent release', 'recent release' ), 'edit_item' => _x( 'Edit recent release', 'recent release' ), 'new_item' => _x( 'New recent release', 'recent release' ), 'view_item' => _x( 'View recent release', 'recent release' ), 'search_items' => _x( 'Search recent releases', 'recent release' ), 'not_found' => _x( 'No recent releases found', 'recent release' ), 'not_found_in_trash' => _x( 'No recent releases found in Trash', 'recent release' ), 'parent_item_colon' => _x( 'Parent recent release:', 'recent release' ), 'menu_name' => _x( 'recent releases', 'recent release' ), ); $args = array( 'labels' => $labels, 'hierarchical' => false, 'supports' => array( 'title', 'editor', 'thumbnail', 'custom-fields' ), 'public' => true, 'show_ui' => true, 'show_in_menu' => true, 'menu_position' => 8, 'menu_icon' => 'https://yourdomain.com/images/menuicon.png', 'show_in_nav_menus' => true, 'publicly_queryable' => true, 'exclude_from_search' => true, 'has_archive' => true, 'query_var' => true, 'can_export' => true, 'rewrite' => true, 'capability_type' => 'page' ); register_post_type( 'recentrelease', $args ); }
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘The best way to query this post type?’ is closed to new replies.