Loading...
Loading...
Use when working with WordPress core APIs in plugins or themes. Covers add_menu_page, add_submenu_page, add_options_page, add_shortcode, add_meta_box, register_post_type, register_taxonomy, HTTP API (wp_remote_request, wp_remote_get, wp_remote_post), wp_schedule_event (WP-Cron), wp_add_dashboard_widget, users and roles (add_role, current_user_can), privacy tools (wp_register_personal_data_exporter), theme mods, site health API, global variables ($wpdb, $post, $wp_query), add_image_size, responsive images, and advanced hooks (do_action, apply_filters, remove_action).
npx skill4agent add peixotorms/odinlayer-skills wp-apisadd_menu_page( $page_title, $menu_title, $capability, $menu_slug, $callback, $icon_url, $position )
add_submenu_page( $parent_slug, $page_title, $menu_title, $capability, $menu_slug, $callback )| Helper Function | Parent Page |
|---|---|
| Dashboard |
| Posts |
| Media |
| Pages |
| Comments |
| Appearance |
| Plugins |
| Users |
| Tools |
| Settings |
admin_menuload-{$hook_suffix}remove_menu_page( $slug )remove_submenu_page( $parent, $slug )add_shortcode( $tag, $callback )
// Callback signature: ( $atts, $content = null, $tag = '' ): string
shortcode_atts( $defaults, $atts, $tag )
do_shortcode( $content ) // Process nested shortcodes in enclosing content.echoesc_attr()esc_html()$tagshortcode_atts()shortcode_atts_{$tag}add_meta_box( $id, $title, $callback, $screen, $context, $priority )
// Contexts: normal | side | advanced
// Priorities: high | core | default | low
remove_meta_box( $id, $screen, $context )save_postwp_verify_nonce()DOING_AUTOSAVEcurrent_user_can( 'edit_post', $post_id )update_post_meta()register_post_type( $post_type, $args )
register_taxonomy( $taxonomy, $object_type, $args )publichas_archiveshow_in_restsupportsrewritemenu_iconcapability_type | Feature Enabled |
|---|---|
| Title field |
| Content editor |
| Featured image |
| Excerpt field |
| Revision history |
| Template + menu order |
| Custom fields meta box |
| Comments |
hierarchicalshow_in_restrewriteshow_admin_column| Template File | When |
|---|---|
| Single CPT post |
| CPT archive |
| Custom taxonomy archive |
| Specific term archive |
initwp_remote_get( $url, $args )
wp_remote_post( $url, $args )
wp_remote_retrieve_response_code( $response )
wp_remote_retrieve_body( $response )
is_wp_error( $response )| Argument | Default | Notes |
|---|---|---|
| | Or |
| | Seconds. Increase for slow APIs. |
| | Max redirects to follow. |
| | Use |
| | Never disable in production. |
| | |
set_transient()get_transient()wp_schedule_event( $timestamp, $recurrence, $hook, $args )
wp_schedule_single_event( $timestamp, $hook, $args )
wp_next_scheduled( $hook, $args )
wp_unschedule_event( $timestamp, $hook, $args )cron_schedulesarray( 'interval' => 300, 'display' => 'Every 5 Minutes' )wp_next_scheduled()wp_unschedule_event()register_deactivation_hookdefine( 'DISABLE_WP_CRON', true )wp cron event run --due-nowwp_add_dashboard_widget( $widget_id, $widget_name, $callback )
// Hook: wp_dashboard_setupadd_meta_box()'dashboard''side'remove_meta_box( $id, 'dashboard', $context )add_role( $role, $display_name, $capabilities )
remove_role( $role )
$role->add_cap( $cap ) // via get_role()
$role->remove_cap( $cap )
current_user_can( $capability )update_user_meta( $user_id, $key, $value )
get_user_meta( $user_id, $key, $single )
delete_user_meta( $user_id, $key )roleorderbyordernumbermeta_querywp_privacy_personal_data_exportersarray( 'data' => [...], 'done' => bool )wp_privacy_personal_data_erasersarray( 'items_removed' => int, 'items_retained' => int, 'messages' => [], 'done' => bool )wp_add_privacy_policy_content( $plugin_name, $policy_text )admin_init$page'done' => falseset_theme_mod( $name, $value )
get_theme_mod( $name, $default )
remove_theme_mod( $name )
get_theme_mods()| Feature | | |
|---|---|---|
| Scope | Per-theme | Global (all themes) |
| Switching themes | Reverts to new theme's values | Persists |
| Storage | Single | Individual option rows |
| Customizer default | Yes ( | Must set |
| Filter | | |
theme_modoptionsite_health_navigation_tabssite_health_tab_contentsite_status_tests$tests['direct']['key'] = array( 'label' => ..., 'test' => $callback )labelstatusbadgedescriptionactionstestdebug_information$info['plugin-slug']['fields']| Variable | Type | Description |
|---|---|---|
| | Current post being processed |
| | Current post's author |
| | Current page of a paginated post |
| | Whether post has |
| | Total pages in paginated post |
| | Whether to show content past |
| Variable | Type | Preferred API |
|---|---|---|
| | No alternative -- use directly |
| | Template tags: |
| | |
| | |
| | |
| | |
| Variable | Type | Description |
|---|---|---|
| | Current admin page filename |
| | Current post type in admin screens |
| | WordPress version number |
| | Database schema version |
| Variable | Type | True when... |
|---|---|---|
| | Running on Apache |
| | Running on Nginx |
| | Running on IIS |
get_queried_object()global $wp_query; $wp_query->get_queried_object()globalglobal $wpdb;$postwp_reset_postdata()$wpdbwp_get_attachment_image( $attachment_id, $size ) // Full <img> with srcset/sizes.
wp_get_attachment_image_srcset( $attachment_id, $size ) // Just srcset string.
wp_get_attachment_image_sizes( $attachment_id, $size ) // Just sizes string.
add_image_size( $name, $width, $height, $crop ) // Register custom size.wp_calculate_image_sizessizeswp_calculate_image_srcsetmax_srcset_image_widthloading="lazy"'loading' => 'eager'remove_action( $hook, $callback, $priority )
remove_filter( $hook, $callback, $priority )
do_action( $hook, ...$args ) // Fire a custom action.
apply_filters( $hook, $value, ...$args ) // Fire a custom filter.| Function | Returns |
|---|---|
| Number of times an action has fired (int). |
| Whether a specific action is currently running. |
| Whether a specific filter is currently running. |
| Name of the action currently being executed. |
| Name of the current filter (works for actions). |
| Whether a callback is registered for an action. |
| Whether a callback is registered for a filter. |
add_action()did_action() > 1save_post@since@param| Mistake | Fix |
|---|---|
| Flushing rewrite rules on every request | Only flush on activation: |
Registering CPTs/taxonomies in | Use |
| Always |
| Saving meta without nonce/capability check | Verify nonce, check |
Scheduling cron without | Always check first or you create duplicate events |
| Not cleaning up cron on deactivation | |
Using | Use |
Disabling | Only disable for local development; never in production |
| Adding roles/caps on every page load | Roles persist in DB -- add on activation, remove on uninstall |
Forgetting | Required for Block Editor and REST API access |
| Not paginating privacy exporters/erasers | Set |
Calling | Must run after the original |
Using | Use |
Modifying | Always call |
Hardcoding image sizes in | Use |
| CPT slug matches a page slug | Individual CPT posts 404 -- use a different rewrite slug or rename the page |
| Default is 1 arg -- pass |
Filters that | Filter callbacks MUST return the modified value; echoing corrupts output |