Mega WordPress
Cheat Sheat
Three. Two. Online
WP-CLI Cheat Sheet
WordPress Theme Development
WordPress Keyboard Cheat Sheet
3 in 1
Mega WordPress Cheat (3 in 1)
Table of Content
Click or tap to jump to any section;
Three. Two. Online
HOSTINGER
WP CLI Cheat Sheet
1
WordPress Themes Development Cheat Sheet
2
2 Defining New Theme
3 WordPress Template Files
4 WordPress Template Anatomy
5 WordPress Template Tags
6 Include Tags
6 Useful Header Functions
6 The Loop
7 WordPress Menus
7 Registering New Sidebar
WordPress Keyboard Shortcuts Cheat Sheet
8
9 Formatting Shortcuts
Start your own website with unlimited hosting.
Use HostingerTutorials Discount Code and
Get Up to 83% OFF for any web hosting plan.
Use It Today
Mega WordPress Cheat (3 in 1)
1
Three. Two. Online
HOSTINGER
WP CLI Cheat Sheet
WP-CLI (WordPress Command Line Interface) is a tool that gives the ability to administrate
WordPress through a command-line interface. You can execute standard functions like plugin
installations and commands that are not supported through the standard WordPress back-end.
Below you can find useful WP CLI commands:
Download WordPress
wp core download
Generate wp-config.php File
wp config create --dbname=<dbname>
--dbuser=<dbuser> --dbpass=<dbpass>
--dbprefix=<dbprefix>
Install WordPress
wp core install --url=<your_domain_name>
--title=<Your Blog Title>
--admin_user=<admin>
--admin_password=<your_password>
--admin_email=<your_email>
Search Plugin
wp plugin search <search keyword>
Install Plugin
wp plugin install <plugin name>
List Installed Plugins
wp plugin list
List Installed Themes
wp theme list
Search for New Themes
wp theme <search keyword>
Install a Theme
wp theme install <theme name>
Activate a Theme
wp theme activate <theme name>
List Posts
wp post list
Edit Post
wp post edit <post ID>
Post Update
wp post update <id>
--post_title=<Your post title>
List WordPress users
wp db query "SELECT user_login,ID
FROM wp_users;"
Change WordPress Post Author
wp post update <post ID>
--post_author=<author ID>
Create a Post
wp post create
--post_status=<publish or
draft> --post_title=<Your
post title> --edit
Login WordPress Database Console
wp db cli
Optimize Database
wp db optimize
Update WordPress
wp core update
Update WordPress Database
wp core update-db
Update All Plugins
wp plugin update --all
Mega WordPress Cheat (3 in 1) 2
Three. Two. Online
HOSTINGER
WordPress Themes Development Cheat Sheet
Details about WordPress theme are stored in the stylesheet.css file. You can see these
details in the Appearance > Theme Editor section. Below you can find an example from the
Twenty Twenty-One theme. Feel free to copy and adapt it to your needs.
Defining New Theme
/*
Theme Name: Twenty Twenty-One
Theme URI: https://wordpress.org/themes/twentytwentyone/
Author: the WordPress team
Author URI: https://wordpress.org/
Description: Twenty Twenty-One is a blank canvas for your ideas
and it makes the block editor your best brush. With new block
patterns, which allow you to create a beautiful layout in a matter
of seconds, this theme’s soft colors and eye-catching — yet
timeless — design will let your work shine. Take it for a spin!
See how Twenty Twenty-One elevates your portfolio, business
website, or personal blog.
Requires at least: 5.3
Tested up to: 5.8
Requires PHP: 5.6
Version: 1.4
License: GNU General Public License v2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Text Domain: twentytwentyone
Tags: one-column, accessibility-ready, custom-colors, custom-menu,
custom-logo, editor-style, featured-images, footer-widgets,
block-patterns, rtl-language-support, sticky-post,
threaded-comments, translation-ready
Twenty Twenty-One WordPress Theme, (C) 2020 WordPress.org
Twenty Twenty-One is distributed under the terms of the GNU GPL.
*/
Mega WordPress Cheat (3 in 1) 3
Three. Two. Online
HOSTINGER
Basic files every WordPress theme should have:
WordPress Template Files
style.css
Theme’s main stylesheet file
single.php
Single post file. Used for displaying a single post
index.php
Main template file
searchform.php
Search form file
archive.php
Archive or Category template file. Will be overridden
if other template files like category.php, author.php,
and date.php exist.
404.php
404 error page file. Will be displayed if WordPress can’t find
the page that visitor requested.
search.php
Search results file
footer.php
Footer content file
comments.php
Comments template file
sidebar.php
Sidebar content file
header.php
Header content file
page.php
Single-page file. Used for pages only
Mega WordPress Cheat (3 in 1) 4
Three. Two. Online
HOSTINGER
WordPress Template Anatomy
header.php
get_header();
sidebar.php
get_sidebar();
footer.php
get_footer();
wp_nav_menu();//
(registered in functions.php) get_search_form();
style.css
theme styles
functions.php
theme functions
comments.php
comments template
Not Displayed:
The Loop
index.php
home.php
archive.php
page.php
single.php
search.php
author.php
404.php
comments_template();
Mega WordPress Cheat (3 in 1) 5
Three. Two. Online
HOSTINGER
WordPress template tags are used in WordPress to display return information dynamically. In
other words, you can use them to customize your WordPress site. For example, the_title() tag
would display the title of the specific post.
WordPress Template Tags
the_content();
Get post content
the_title();
Get the title of the post
the_excerpt();
Get the post excerpt
the_category(', ')
Display category of a post
the_permalink()
Display post link
the_ID();
Display post ID
the_author();
Show post author
next_post_link(' %link ')
Display next page URL
edit_post_link();
Show Edit link for a post
get_links_list();
Retrieve blogroll links
previous_post_link('%link')
Display previous page URL
wp_list_pages();
Retrieve all pages
wp_get_archives()
Retrieve archive for the site
get_calendar();
Show the built-in WordPress calendar
wp_list_cats();
Retrieve all categories
wp_loginout();
Displays login or logout links (for
registered users)
wp_register();
Show register link
Mega WordPress Cheat (3 in 1) 6
Three. Two. Online
HOSTINGER
Use these tags to include templates to your theme.
Include Tags
<?php get_header(); ?>
Includes header.php and displays its content.
<?php get_footer(); ?>
Includes the footer.php.
<?php get_sidebar(); ?>
Includes sidebar.php.
<?php comments_template(); ?>
Load specific template for comments.
The Loop is PHP code used by WordPress to return posts. The Loop processes an individual
post and displays it on the current page. It also formats the post according to how it matches
specified parameters. Any HTML or PHP code in the Loop will be processed on each post.
The Loop
Useful Header Functions
site_url();
Get WordPress site url
bloginfo('name');
Get blog name
wp_title();
Get page title
bloginfo('description');
Get blog description
get_stylesheet_directory_uri();
Get stylesheet directory URI
bloginfo('template_url');
Get pat template folder
bloginfo('atom_url');
Get Atom feed URL
bloginfo('rss2_url');
Get RSS 2.0 URL
<?php
if ( have_posts() ) :
while ( have_posts() ) : the_post();
// Display post content
endwhile;
endif;
?>
Mega WordPress Cheat (3 in 1) 7
Three. Two. Online
HOSTINGER
WordPress Menus
Add the following code to your functions.php file to register a new sidebar.
Registering New Sidebar
add_action( 'widgets_init', 'theme_slug_widgets_init' );
function theme_slug_widgets_init() {
register_sidebar( array(
'name' => __( 'My Sidebar', 'theme-slug' ),
'id' => 'sidebar-1',
'description' => __( 'Description', 'theme-slug' ),
'before_widget' => '<li id="%1$s" class="widget %2$s">',
'after_widget' => '</li>',
'before_title' => '<h2 class="widgettitle">',
'after_title' => '</h2>',
) );
}
<?php wp_nav_menu(); ?>
Default Navigation Menu
<?php wp_nav_menu( array('menu'
=> My Navigation' )); ?>
Specific Navigation Menu
<ul id="menu">
<li <?php if(is_home()) { ?> class="current-cat" <?php } ?>>
<a href="<?php bloginfo('home'); ?>">Home</a>
</li>
<?php wp_list_categories('title_li=&orderby=id');?>
</ul
Category Based Navigation
<ul id="menu">
<li <?php if(is_home()) { ?> class="current-page-item" <?php } ?>>
<a href="<?php bloginfo('home'); ?>">Home</a>
</li>
<?php wp_list_pages('sort_column=menu_order&depth=1&title_li=');?>
</ul>
Page Based Navigation
Mega WordPress Cheat (3 in 1) 8
Three. Two. Online
HOSTINGER
WordPress Keyboard Shortcuts Cheat Sheet
Windows and Linux use Ctrl + Letter
Mac uses Command + Letter
c
v
a
x
z
Copy
Paste
Select all
Cut
Undo
y
b
i
u
k
Redo
Bold
Italic
Underline
Insert/edit link
Ctrl + Key
The following shortcuts use a different key combination:
Windows and Linux: Alt + Shift + Letter
Mac: Ctrl + Option (alt) + Letter (Macs running any WordPress
version below 4.2 use Alt + Shift + Letter)
n
l
j
c
d
r
u
x
Check spelling
(requires a plugin)
Align left
Justify text
Align center
Strikethrough
Align right
• List
Add/remove code tag
a
o
s
q
m
w
t
p
Insert link
1. Link
Remove link
Quote
Insert image
Distraction-free writing mode
Insert more tag
Insert page break tag
h
1
2
3
4
5
6
9
Help
Heading 1
Heading 2
Heading 3
Heading 4
Heading 5
Heading 6
Address
Alt + Shift
+ Key
Mega WordPress Cheat (3 in 1) 9
Three. Two. Online
HOSTINGER
Formatting Shortcuts
Formatting Shortcuts while using a visual editor.
*
-
1.
1)
##
###
####
#####
######
>
---
‘..’
Start an unordered list
Start an unordered list
Start an ordered list
Start an ordered list
H2
H3
H4
H5
H6
Transform text into blockquote
Horizontal line
Transform text into code block
Start your own website with unlimited hosting.
Use HostingerTutorials Discount Code and
Get Up to 83% OFF for any web hosting plan.
Use It Today