|
wp-includes/rest-api/search/class-wp-rest-post-search-handler.php:
WP_REST_Post_Search_Handler::__construct()
|
Constructor.
|
|
wp-includes/rest-api.php:
create_initial_rest_routes()
|
Registers default REST API routes.
|
|
wp-includes/rest-api/endpoints/class-wp-rest-users-controller.php:
WP_REST_Users_Controller::get_items_permissions_check()
|
Permissions check for getting all users.
|
|
wp-includes/rest-api/endpoints/class-wp-rest-users-controller.php:
WP_REST_Users_Controller::get_items()
|
Retrieves all users.
|
|
wp-includes/rest-api/endpoints/class-wp-rest-users-controller.php:
WP_REST_Users_Controller::get_item_permissions_check()
|
Checks if a given request has access to read a user.
|
|
wp-includes/rest-api/endpoints/class-wp-rest-post-statuses-controller.php:
WP_REST_Post_Statuses_Controller::check_read_permission()
|
Checks whether a given post status should be visible.
|
|
wp-includes/rest-api/endpoints/class-wp-rest-post-statuses-controller.php:
WP_REST_Post_Statuses_Controller::get_items_permissions_check()
|
Checks whether a given request has permission to read post statuses.
|
|
wp-includes/rest-api/endpoints/class-wp-rest-post-types-controller.php:
WP_REST_Post_Types_Controller::get_items_permissions_check()
|
Checks whether a given request has permission to read types.
|
|
wp-includes/rest-api/endpoints/class-wp-rest-post-types-controller.php:
WP_REST_Post_Types_Controller::get_items()
|
Retrieves all public post types.
|
|
wp-includes/embed.php:
get_post_embed_url()
|
Retrieves the URL to embed a specific post in an iframe.
|
|
wp-admin/includes/class-wp-screen.php:
WP_Screen::render_view_mode()
|
Render the list table view mode preferences.
|
|
wp-includes/class-wp-customize-nav-menus.php:
WP_Customize_Nav_Menus::search_available_items_query()
|
Performs post queries for available-item searching.
|
|
wp-includes/class-wp-customize-nav-menus.php:
WP_Customize_Nav_Menus::available_item_types()
|
Return an array of all the available item types.
|
|
wp-admin/includes/export.php:
export_wp()
|
Generates the WXR export file for download.
|
|
wp-admin/includes/misc.php:
set_screen_options()
|
Saves option for number of rows when listing posts, pages, comments, etc.
|
|
wp-admin/includes/user.php:
wp_delete_user()
|
Remove user and optionally reassign posts and links to another user.
|
|
wp-admin/includes/post.php:
wp_edit_posts_query()
|
Run the wp query to fetch the posts for listing on the edit posts page
|
|
wp-admin/includes/ajax-actions.php:
wp_ajax_menu_get_metabox()
|
Ajax handler for retrieving menu meta boxes.
|
|
wp-admin/includes/ajax-actions.php:
wp_ajax_find_posts()
|
Ajax handler for querying posts for the Find Posts modal.
|
|
wp-admin/includes/class-wp-terms-list-table.php:
WP_Terms_List_Table::__construct()
|
Constructor.
|
|
wp-admin/includes/nav-menu.php:
wp_nav_menu_post_type_meta_boxes()
|
Creates meta boxes for any post type menu item.
|
|
wp-includes/class-wp.php:
WP::parse_request()
|
Parse request to find correct WordPress query.
|
|
wp-includes/class-wp-query.php:
WP_Query::get_posts()
|
Retrieves an array of posts based on query variables.
|
|
wp-includes/class-wp-embed.php:
WP_Embed::cache_oembed()
|
Triggers a caching of all oEmbed results.
|
|
wp-includes/link-template.php:
get_permalink()
|
Retrieves the full permalink for the current post or post ID.
|
|
wp-includes/link-template.php:
get_attachment_link()
|
Retrieves the permalink for an attachment.
|
|
wp-includes/admin-bar.php:
wp_admin_bar_new_content_menu()
|
Add “Add New” menu.
|
|
wp-includes/class-wp-user-query.php:
WP_User_Query::prepare_query()
|
Prepare the query variables.
|
|
wp-includes/post.php:
_get_last_post_time()
|
Gets the timestamp of the last time any post was modified or published.
|
|
wp-includes/post.php:
get_pages()
|
Retrieve a list of pages (or hierarchical post type items).
|
|
wp-includes/post.php:
_add_post_type_submenus()
|
Add submenus for post types.
|
|
wp-includes/class-wp-rewrite.php:
WP_Rewrite::generate_rewrite_rules()
|
Generates rewrite rules from a permalink structure.
|
|
wp-includes/rewrite.php:
url_to_postid()
|
Examine a URL and try to determine the post ID it represents.
|
|
wp-includes/canonical.php:
redirect_guess_404_permalink()
|
Attempts to guess the correct URL based on query vars
|
|
wp-includes/class-wp-xmlrpc-server.php:
wp_xmlrpc_server::wp_getPostTypes()
|
Retrieves a post types
|
|
wp-includes/comment.php:
do_all_pings()
|
Perform all pingbacks, enclosures, trackbacks, and send to pingback services.
|
|
wp-includes/class-wp-editor.php:
_WP_Editors::wp_link_query()
|
Performs post queries for internal linking.
|
Argument values for $args include:
Output a list of only custom post types which are public
By setting
'_builtin'tofalse, we exclude the WordPress built-in public post types (post,page,attachment,revision, andnav_menu_item) and retrieve only registered custom public post types.<?php $args = array( 'public' => true, '_builtin' => false ); $output = 'names'; // 'names' or 'objects' (default: 'names') $operator = 'and'; // 'and' or 'or' (default: 'and') $post_types = get_post_types( $args, $output, $operator ); if ( $post_types ) { // If there are any custom public post types. echo '<ul>'; foreach ( $post_types as $post_type ) { echo '<li>' . $post_type . '</li>'; } echo '<ul>'; } ?>Expand full source codeCollapse full source code
Retrieve a named post type as an object
This example uses the
'object'output to retrieve the post type called ‘movies’ and display its name, singular name and menu icon (an URL):<?php $args = array( 'name' => 'movies', ); $post_types = get_post_types( $args, 'objects' ); foreach ( $post_types as $post_type ) { echo '<p>Custom Post Type name: ' . $post_type->name . "<br />\n"; echo 'Single name: ' . $post_type->labels->singular_name . "<br />\n"; echo 'Menu icon URL: ' . $post_type->menu_icon . "</p>\n";; } ?>Default Usage
Retrieves the names (in an array) of all built-in and custom post types.
Output a list of the names of all registered post types
Uses
'names'as$outputargument value.<?php $post_types = get_post_types( '', 'names' ); echo '<ul>'; foreach ( $post_types as $post_type ) { echo '<li>' . $post_type . '</li>'; } echo '</ul>'; ?>Display the HTML dropdown list of Post Types.
<?php // Get post types $args = array( 'public' => true, ); $post_types = get_post_types( $args, 'objects' ); ?> <select class="widefat" name="post_type"> <?php foreach ( $post_types as $post_type_obj ): $labels = get_post_type_labels( $post_type_obj ); ?> <option value="<?php echo esc_attr( $post_type_obj->name ); ?>"><?php echo esc_html( $labels->name ); ?></option> <?php endforeach; ?> </select>Expand full source codeCollapse full source code
Get post types array with name => singular name
function prefix_get_post_types() { $post_types = get_post_types([], 'objects'); $posts = array(); foreach ($post_types as $post_type) { $posts[$post_type->name] = $post_type->labels->singular_name; } return $posts; }You can use this function in a select dropdown option where user can select a post type form existing post types.