WordPress Functions

Post Basics

<?php the_title(); ?>
<?php the_content(); ?>
<?php the_excerpt(); ?>
<?php the_ID(); ?>
<?php the_permalink(); ?>
<?php the_post(); ?>
<?php the_meta(); ?>
<?php the_post_thumbnail(); ?>
<?php the_post_thumbnail('thumbnail'); ?>
<?php the_post_thumbnail('medium'); ?>
<?php the_post_thumbnail('large'); ?>
<?php the_post_thumbnail_url(); ?>
<?php get_the_post_thumbnail_url(); ?>
<?php get_permalink(); ?>
<?php get_the_title(); ?>
<?php get_the_excerpt(); ?>
<?php get_the_content(); ?>

Dates & Time

<?php the_date(); ?>
<?php the_time(); ?>
<?php the_modified_date(); ?>
<?php the_modified_time(); ?>
<?php get_the_date(); ?>
<?php get_the_time(); ?>
<?php get_the_modified_date(); ?>
<?php get_the_modified_time(); ?>

Author

<?php the_author(); ?>
<?php the_author_meta('email'); ?>
<?php the_author_meta('ID'); ?>
<?php the_author_posts(); ?>
<?php the_author_posts_link(); ?>

Categories, Tags, Taxonomies

<?php the_category(); ?>
<?php the_category(', '); ?>
<?php the_tags(); ?>
<?php the_tags('', ', '); ?>
<?php the_terms(get_the_ID(), 'taxonomy_name'); ?>
<?php get_the_category(); ?>
<?php get_the_tags(); ?>

Loop Control

<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<?php endwhile; endif; ?>
<?php rewind_posts(); ?>
<?php wp_reset_postdata(); ?>

Templates & Includes

<?php get_header(); ?>
<?php get_footer(); ?>
<?php get_sidebar(); ?>
<?php get_template_part('template-parts/content'); ?>
<?php locate_template(); ?>
<?php include(TEMPLATEPATH . '/file.php'); ?>

<?php if (have_posts()) : ?>
  <?php while (have_posts()) : the_post(); ?>
    <?php get_template_part('loop', 'minimal'); ?>
  <?php endwhile; ?>
<?php else : ?>

<?php else : ?>
  <p>No posts found.</p>
<?php endif; ?>
<?php the_posts_pagination(); ?>

Custom Fields (Post Meta)

<?php get_post_meta(get_the_ID(), 'meta_key', true); ?>
<?php update_post_meta(get_the_ID(), 'meta_key', 'value'); ?>
<?php delete_post_meta(get_the_ID(), 'meta_key'); ?>

$pros = get_post_meta(get_the_ID(), 'site_pros', true);

$status        = $meta('site_status', 'Active');
$age      = $meta('cpt_age', '2020');

Attachment & Media

<?php wp_get_attachment_url($attachment_id); ?>
<?php wp_get_attachment_image($id, 'full'); ?>
<?php wp_get_attachment_image_src($id, 'medium'); ?>

Pagination & Navigation

<?php the_posts_pagination(); ?>
<?php previous_post_link(); ?>
<?php next_post_link(); ?>
<?php posts_nav_link(); ?>
<?php get_next_posts_link(); ?>
<?php get_previous_posts_link(); ?>

Pages

<?php wp_list_pages(); ?>
<?php get_pages(); ?>
<?php the_page(); ?>

Search & Forms

<?php get_search_form(); ?>
<?php the_search_query(); ?>

Comments

<?php comments_template(); ?>
<?php comment_form(); ?>
<?php wp_list_comments(); ?>
<?php get_comments_number(); ?>

Theme Functions / Site Info

<?php bloginfo('name'); ?>
<?php bloginfo('description'); ?>
<?php bloginfo('url'); ?>
<?php bloginfo('template_url'); ?>
<?php wp_title(); ?>
<?php wp_head(); ?>
<?php wp_footer(); ?>
<?php body_class(); ?>
<?php post_class(); ?>

Menu & Navigation

<?php wp_nav_menu(); ?>
<?php has_nav_menu('primary'); ?>
<?php register_nav_menus(); ?>

Login / User Info

<?php is_user_logged_in(); ?>
<?php wp_login_url(); ?>
<?php wp_logout_url(); ?>
<?php get_current_user_id(); ?>
<?php wp_get_current_user(); ?>

Leave a Comment