WordPress Questions Flashcards
What is the latest version of WordPress (as of 6.25.24) and what are some of the major features?
6.5.5 - Addressed some cross-site scripting (XSS) vulnerabilities
What is the WordPress Loop?
The WordPress Loop is a php code used to display posts. It processes each post to be displayed on the current page.
How do you create a child theme in WordPress?
Create a new folder in the “/wp-content/themes/” directory, add a style.css file with the meta comments/theme header and import the parent theme’s stylesheet and optionally add a function.php file.
What is the function of “wp_enqueue_script()’
It safely adds Javascript files to your WordPress site, and you can combine it with other functions to intelligently load your script only on pages where your shortcode is present by using a global flag variable in your shortcode output function (set default to false), then hook your enqueue function in ‘wp_enqueue_scripts’ and conditionally enqueue based on your global variable.
How can you add custom post types in WordPress?
Use the “register_post_type()” function.
What is the purpose of hooks in WordPress?
Hooks allow developers to add their own code into WordPress’ core functionality without modifying core files.
What is the difference between actions and filters?
Actions allow you to add or modify functionality at certain points during the execution of WordPress.
Filters allow you to modify data that is sent back/forth to the database.
How do you create a custom WordPress Plugin?
Create a new PHP file in the “wp-content/plugins” directory, add a plugin header, and then write your code!
<?php
/*
Plugin Name: My First Plugin
Description: This is my first plugin! It makes a new admin menu link!
Author: Your Name
*/
What is the function of “add_theme_support()”
It enables various theme features such as post thumbnails, custom headers, and backgrounds.
If attached to a hook, it must be ‘after_setup_theme’. The ‘init’ hook may be too late for some features.
How can you secure your WordPress site?
Keep themes, plugins, and core up-to-date
Rewrite or move the wp-login.php page
Setup 2FA
Strong password policy and forced resets every 3-6 months
Regular backups
IP restrict “/wp-content/” directory (make exceptions for login/out)
What is the REST API in WordPress?
The REST API provides a way to interact with WordPress from outside the WordPress installation, allowing developers to send and receive data as JSON - this is a requirement for headless WordPress installations.
How do you debug in WordPress?
Set the “WP_DEBUG” environment variable to “true” in ‘wp-config,’ or you can monitor the log file (debug.log) if on the production site.
What is ‘wp_head()’ used for?
It is a template tag used to insert elements in the ‘<head>’ section of a WordPress site.
How do you create a custom taxonomy?
Use the ‘register_taxonomy()’ function.
What are WordPress template hierarchy and its importance?
It determines which template file WordPress uses for each page. It allows for customization and flexibility in theme development.
Examples:
index.php
home.php
front-page.php
page.php
page-{slug}.php – If the page slug is privacy, WordPress will look to use page-privacy.php.
page-{id}.php – If the page ID is 6, WordPress will look to use page-6.php.
single.php
How can you optimize WordPress performance?
Use caching, asset delivery optimization, image compression and lazy loading, use a CDN, and keep the database optimized.
Explain the role of ‘functions.php’ in WordPress.
Functions.php is a boilerplate file within your theme and can be used to add features and functionality to your WordPress site.
What is the purpose of ‘wp_reset_postdata()’?
It resets the global $post object to the current post in the main query after a custom query has been run.
How doy ou change the URL structure in WordPress?
By modifying the permalink settings in the WordPress admin under settings > permalinks. Or can be modified further by utilizing the “Custom Permalinks” plugin.
What is your preferred plugin for SEO?
Yoast Premium is the industry standard in many cases, but my favorite is SmartCrawl by WPMUDev. They have an incredible feature that allows you to auto-insert links into pages based on keywords.