WordPress Cheatsheet

A quick reference

Robert M Ricci
Jun 4 · 6 min read
Photo by Souvik Banerjee on Unsplash

As I spend more time using WordPress I have come to really appreciate some of its features. The simplicity in which you can customize and add features really shows why it is so used. Today I’m going to go over some of those features. We are going to discuss themes, plugins, and forms. Specifically, I am going to talk about the Understrap theme, Advanced Custom Fields plugin, and Gravity Forms which is technically a plugin, but with a very specific purpose. I am going to talk a little about all three, and then add some specific actions that I think are useful.

Themes allow you to quickly style your site, without a ton of coding. Now, this is great if you are creating your own site and don’t have a lot of time, or aren’t a developer. There are thousands of themes, but the one I want to talk about a little is the Understrap theme. What I’ve been enjoying about this theme is the fact that it’s pretty barebones. It gives you some basic styling, but nothing too dramatic. It comes with some bootstrap, sass, npm support, as well as gulp as a task runner.

Understrap comes standard with one set menu, which is located on the top left of the page. It is set in the header file. You can add more menus if you like, and that's exactly what I’m going to show you what to do. This only takes a few steps, but it can get kind of confusing your first time, so I will walk you through it.

The first thing you need to do is go into your WordPress backend. Go down to appearance and select menus. There you can create a new menu.

Name the menu whatever you would like. I usually try to be descriptive if I can. After you click create, you will be able to add any pages or posts you have created. Now comes the trickier part, you will need to go into your functions.php file in your text editor. You will add the below code in that file, replacing the names with the names of your menu(s).

function wpb_custom_new_menu() {register_nav_menus(array(     'menu-2' => __( 'Menu 2' ),     'extra-menu' => __( 'Extra Menu' )) ); }add_action( 'init', 'wpb_custom_new_menu' );

You will then add this code where ever you want your menu placed.

<?phpwp_nav_menu( array('theme_location' => 'menu-2','container_class' => 'menu-two-class' ) );?>

Plugins just like themes allow you to add features and customize themes. Again, there are thousands of plugins, that can do anything from spam protection to newsletter sign-ups, to google analytics. The one I’m going to talk about today is Advanced Custom Fields. ADF allows you to add your own fields to your pages in wordpress. This makes it easy to add text, images, or links.

Once you have the plugin installed and activated you can go to work. The first thing you will need to do is go to the ADF tab on the side menu bar. Select add-new. You will then need to name the custom fieldset. ≈

The field name will be auto-generated after you put in the field label. Remember that you will need it shortly. Once you have entered your fields, you will need to select a location.

You will want to select where ever you want to put your field group. Since I will be making pages, I selected a page template, and right now I have the default template selected. I would probably have created a new template for the page I was making and selected that. Field groups can be in multiply locations, so you can reuse your field groups.

To place your field on a page you will again need to go into your text editor and add it to whichever template you selected. This is more or less the code you will need. It will need to be wrapped in PHP tags. You will use the keyword the_field, the word in quotes is the field name. You would also need to wrap the whole thing in an HTML tag so that it shows up on the screen.

     <h2>  <?php the_field('name') ?>. </h2>

Sure you could create a form using HTML, and then style it with CSS, but who really have time for all that. Form plugins are great for generating forms for any part of your site. The best part is that you can make multiple and just plug them in where you need to. The one that I recently started using is Gravity Forms.

Similairly to Advance Custom Fields, Gravity Forms gets it’s own spot on the dashboard sidebar. Simply click add new, adn you will be prompted to name your from as well as provide a desription. Once you do that you can create a form to your liking. The editor allows you to add custom lines, as well as some presets.

Then to place the form you will need to go into your text editor, and put it where ever you want it. You have some options when it comes to adding a form. Here is all the options.

gravity_form( $id_or_title, $display_title = true,  
$display_description = true, $display_inactive = false,
$field_values = null, $ajax = false, $tabindex, $echo = true );

Here is what they mean:

  • $id_or_title
    (mixed) (required) The id or title of the form to be embedded.
  • $display_title
    (boolean) (optional) Whether or not to display the form title.
    Defaults to true.
  • $display_description
    (boolean) (optional) Whether or not to display the form description.
    Defaults to true.
  • $display_inactive
    (boolean) (optional) Whether or not to display the form even if it is inactive.
    Defaults to false.
  • $field_values
    (array) (optional) Pass an array of dynamic population parameter keys with their corresponding values to be populated.
    Example: “array(‘parameter_name’ => ‘custom_value’)”
    Defaults to false.
  • $ajax
    (boolean) (optional) Whether or not to use AJAX for form submission.
    Defaults to false.
  • $tabindex
    (integer) (optional) Specify the starting tab index for the fields of this form.
  • $echo
    (boolean) (optional) Whether to echo the form code or return it.
    Defaults to true.

So a basic call would look something like this. This snippet will display the form with an id of ‘1’; the title and description will not be displayed, the form itself will not display if it is inactive, and it will not use AJAX for form submission.

gravity_form( 1, false, false, false, '', false );

WordPress is already a conveinent way to create websites. With the usuage of themes and plugins it becomes even better. I’ve been really enjoying learning about WordPRess and all of its functionality. What are your favorite plugins? Let me know.

Geek Culture

Proud to geek out. Follow to join our +500K monthly readers.

Medium is an open platform where 170 million readers come to find insightful and dynamic thinking. Here, expert and undiscovered voices alike dive into the heart of any topic and bring new ideas to the surface. Learn more

Follow the writers, publications, and topics that matter to you, and you’ll see them on your homepage and in your inbox. Explore

If you have a story to tell, knowledge to share, or a perspective to offer — welcome home. It’s easy and free to post your thinking on any topic. Write on Medium

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store