The tweet scheduling plugin for WordPress
WordPress Quick Reference
WordPress Quick Reference

WordPress Quick Reference

This is a super-abbreviated reference to the WordPress codex with links to the documentation. It doesn’t cover everything, or explain anything!

It links to commonly used stuff for coding themes, custom pages, and plugins. It also includes links to a few useful resources.

If you find anything missing and want to add to this page, please leave a comment!

Overview Docs

Database

$wpdb, get_var, get_row=>object, get_col=>array, get_results=>array(object),

$wpdb->query ($wpdb->prepare(statement,vars))

$wpdb->insert(table,col_array,fmt_array)
$wpdb->replace(table,col_array,fmt_array) (update or insert)
$wpdb->update(table,col_array,match_array,fmt_array,match_fmt)
$wpdb->delete(table,match_array,match_fmt)

The Loop

new WP_Query, wp_reset_postdata

have_posts()?  is_day, is_month, is_year, tag_description, category_description, get_post_format_string

while ( have_posts() ) :
the_post();
$post=$current_post,
post_password_required

the_title, the_content, the_excerpt, get_the_date, get_post_meta, the_permalink

get_post_gallery, has_post_thumbnailthe_post_thumbnail

get_the_author, get_author_posts_url, get_the_author_meta: ID, description, user_email, user_url

Theme Content

bloginfo: name, description, charset, pingback_url

wp_title, wp_head, wp_footer / get_header, get_sidebar, get_footer

wp_nav_menu, get_search_form, get_post_meta, get_post_class, get_the_terms

get_sidebar: is_active_sidebar, dynamic_sidebar

wp_link_pages,  edit_post_link

is_search, is_single

home_url, get_template_directory_uri

get_template_part ( “content”, get_post_format() );

comments_template: comment_form, have_comments: get_comments_number, wp_list_comments, comments_open

do_shortcode  ([html]): expand shortcodes

do_action(“custom_theme_hook”): use a template tag

add_action(“custom_theme_hook”,”template_tag”) to add content generator

Theme Configuration (functions.php)

add_action( “after_setup_theme“, “theme_setup” ): register_nav_menu

add_action( “wp_enqueue_scripts“,”theme_styles”): wp_enqueue_style

add_action( “widgets_init”,”theme_widgets”): register_sidebar

Theme Customizer

add_action(“init”,”init_theme_vars”):
get_theme_mod,
set_theme_mod

add_action(“customize_register“,”register_theme_settings”):
$wp_cust-> add_section,
$wp_cust->add_setting,
$wp_cust->add_control, WP_Customize_Control

add_action( “wp_head”, “setup_theme_styles”, 12 ):

add_action( “admin_print_styles-appearance_page_custom-header”, “config_header_fonts” ):  wp_enqueue_style

Plugins

defined(“ABSPATH”) or die(“Access not permitted”)

register_activation_hook(__FILE__,”activation_function”)

register_deactivation_hook(__FILE__,”deactivation_function”)

register_uninstall_hook(__FILE__,”uninstall_function”)

add_shortcode ( “shortcode”, “shortcode_generator” ), shortcode_atts
RETURN don”t echo!

wp_mail ( $to, $subject, $message, $headers, $attachments )

wp_remote_get ($url, $args), wp_remote_post ($url, $args)

wp_schedule_event (time(), “hourly”, “cron_function”))

wp_clear_scheduled_hook (“cron_function”) or

wp_unschedule_event (wp_next_scheduled(“cron_function” ),”cron_function”)

Widgets

class my_widget extends WP_Widget {\r\nfunction plugin_widget() {}
// Constructor: $this->WP_Widget(“widget_id”,”title”,$options)

function form($instance) {}
// ECHO config form contents

function update($new,$old) {}
// Save changes

function widget($args,$instance) {}
// Display widget

}

add_action(“widgets_init”,”my_widget_init”):
register_widget (“my_widget”)

AJAX

add_action( “wp”, “my_ajax_init”): wp_register_scriptwp_enqueue_script

wp_localize_script ( “[script_id]”, “MyAjax”, array(\r\n”ajaxurl” => admin_url( “admin-ajax.php” ),
“verifyNonce” => wp_create_nonce(“[unique_nonce_id]”)))

add_action( “wp_ajax_[jsaction]”, “post_function” );

add_action( “wp_ajax_nopriv_[jsaction]”, “post_function” );

jQuery: $.post(MyAjax.ajaxurl,{ action: “[jsaction]”, verifyNonce: MyAjax.verifyNonce, [post_vars] })

Users

get_users = array[WP_User]: ID, roles, first_name, last_name, display_name, user_email, user_nicename…

wp_get_current_user, wp_signon, is_user_logged_in, is_author, is_admin

get_user_meta, update_user_meta, add_user_meta, delete_user_meta

wp_generate_password, wp_insert_user, wp_update_user, username_exists, email_exists

Action Hooks: user_register, profile_update

Customizing the Login Form

Custom Post Types / Post Meta Data

add_action( “init”,”setup_custom_post_types”): register_post_type

add_filter( “manage_edit-[post_type]_columns“, “admin_[post_type]_columns”)

add_action( “manage_[post_type]_posts_custom_column“, “[post_type]_column_values”, 10, 2)

add_filter(“manage_edit-[post_type]_sortable_columns“, “[post_type]_custom_sort”)

add_action( “add_meta_boxes“, “my_post_metaboxes”): add_meta_box: get_post_meta, get_post_custom

add_action( “add_meta_boxes_[post_type]“, “[post_type]_metaboxes”)

add_action( “save_post“, “save_[post_type]_settings”, 10, 2 ): update_post_meta

Custom Taxonomies / Taxonomy “Meta Data”

add_action( “init”,”setup_custom_taxonomies”): register_taxonomy

Note: this is kind of hack-ish using the options table for taxonomy metadata

add_action( “[taxonomy]_add_form_fields”, “add_form_[taxonomy]_fields”, 10, 2 )

add_action( “[taxonomy]_edit_form_fields”, “edit_form_[taxonomy]_fields”, 10, 2 ) :
get_option( “taxonomy_$t_id” )

add_action( “edited_[taxonomy]”, “save_[taxonomy]_meta”, 10, 2 )

add_action( “create_[taxonomy]”, “save_[taxonomy]_meta”, 10, 2 ) :
update_option( “taxonomy_$t_id”, $meta )

see this article for implementation details

Admin Options

add_action(“admin_menu“,”init_admin_menu”):
add_options_page

add_action(“admin_init“,”init_admin_settings”):
register_setting

Useful Resources

Moving a WordPress Website Without Hassle – Smashing Magazine

SumoMe website tools

Leave a Reply

Your email address will not be published. Required fields are marked *