1: Wordpress latest version : 6.0.2
2 : How to create a plugin in WordPress?
The following steps will guide you through creating your first plugin:
- Connect to your site via FTP (File Transfer Protocol).
- Navigate to the WordPress plugins folder after gaining access to your site via FTP. This folder is usually located in /wp-content/plugins.
- After you've navigated into the plugins folder, you can create a folder of your own. Create a new folder with a unique name that uses lowercase letters and dashes, for example, first_plugin. Once you've done that, choose your new folder and continue.
- You will then need to create the main plugin file.
- Then, create a file named very-first-plugin.php in your new plugin folder.
- The plugin information can now be copied and pasted into your newly created main plugin file. Make sure to modify plugin details such as Plugin URL and Plugin Name.
WordPress has the following minimal requirements:
- PHP version 7.2 or higher.
- A MySQL version of 5.6 or higher OR a MariaDB version of 10.0 or higher.
- Support for HTTP.
- The best servers for running WordPress are Nginx or Apache, but any server that supports MySQL and PHP will work.
In WordPress databases, the shelves are called tables. By default, WordPress websites contain 12 tables. Only certain data can be stored in each table. WordPress comments tables, for example, contain information regarding IP addresses, comment author slugs, etc., of people who have commented on a post. In this way, data can be stored and retrieved more quickly.
5. What are the basic steps we should take when our WordPress website is hacked?
Since WordPress is one of the most popular CMS platforms on the web, its security is paramount. Upon analyzing the existing loopholes, standard security policies should be implemented in WordPress to protect WordPress data. The steps that must be taken when your WordPress platform is hacked are as follows:
- Keep calm and seek an optimal solution.
- Track down the hack.
- Contact your web hosting provider.
- Get an InfoSec expert to help you.
- Download and install a security plugin, such as WordPress security.
- Locate, scan, and fix/remove malware.
- Ensure that your access permissions are correct.
- Also, update WordPress to its latest version.
- Update all user IDs and passwords.
- Check to make sure that your plugins and themes are up to date.
6. How to increase WordPress website security?
Despite being a safe CMS (content management system), WordPress is susceptible to attacks, just like any other CMS. WordPress security can be enhanced in many ways, as follows:
- Login procedures should be secure.
- Consider using a secure WordPress hosting provider.
- Update the WordPress version.
- Upgrade the PHP version.
- Download and install security plugins.
- Select a secure theme for WordPress.
- Enable SSL (Secure Socket Layer) or HTTPS (HyperText Transfer Protocol Secure) for your site.
- Set up a firewall.
- Make a backup of your site.
- Manage user permissions on WordPress.
- Change the default login URL of WordPress.
- Disable xmlrpc.php file.
- Disable editing files within the WordPress dashboard.
- Modify the database file prefix.
- Delete the default WordPress administrator account.
- Hide the WordPress version.
WordPress developers are able to create custom post types. The register_post_type() function may be used to add a custom post type. Plugins allow us to create custom post types as well.
- Custom Post Type UI
- Custom Field
Wp_posts is a table in your MySQL database that holds the content of your WordPress posts and pages. WordPress displays your content using dynamic PHP templates, so it doesn't store a separate HTML file for each page. In the database, you can also find "Pages" (or other custom post types available in WordPress) in the wp_posts table. Typically, these can be accessed through phpMyAdmin.
9 : List a few template tags that can be used in WordPress.
The following are some template tags you can use in WordPress.
- get_header()
- get_footer()
- get_sidebar()
- wp_login_url()
- get_calendar()
- allowed_tags()
- the_author()
- get_the_author()
- wp_list_bookmarks()
- get_bookmark()
- the_category()
- the_category_rss()
- comment_author()
- comment_author_email()
- the_permalink()
- user_trailingslashit()
- permalink_anchor()
- post_class()
- post_password_required()
- get_post_thumbnail_id()
- the_post_thumbnail()
- wp_nav_menu()
- walk_nav_menu_tree(), etc
Whenever you wish to alter or customize something in WordPress, you can almost certainly make use of a hook. WordPress hooks enable you to manipulate the behavior of a procedure without having to modify the WordPress core files. With hooks, you can modify or add new features to WordPress without modifying the core files.
11 : What is Action and Filter Hooks?
Action and Filter are types of WordPress Hooks.
- Action Hooks: Actions enable you to perform a task at predefined points during the WordPress runtime. In the WordPress code, actions are defined as follows:
do_action( 'action_name', [optional_arguments] );
Here, the 'action_name' string represents the name of the action. If you would like to pass additional arguments to the callback function, you can specify the [optional_arguments] variable. When no value is specified, this field is empty by default.
- Filter Hooks: Filters allow you to modify and return any data processed by WordPress. In the WordPress code, filters are defined as follows:
apply_filters( 'filter_name', 'value_to_be_filtered', [optional_arguments] );
Here, the ‘filter_name’ string represents the name of the filter. 'value_to_be_filtered' represents the value that has to be filtered and returned. In the same way as actions, the [optional_arguments] variable can pass additional arguments
12 : Explain shortcode in WordPress.
A shortcode is a small chunk of code, placed between brackets like [yourshortcode], that performs a specific function for your site. It can be placed anywhere to provide a specific feature to a page, post, or other content. WordPress shortcodes make it easy to add dynamic content to pages, posts, and sidebars. Several WordPress plugins and themes offer shortcodes for adding specialized content to websites, such as sliders, image galleries, contact forms, and more.
13 : What is a Child theme in WordPress?
A child theme inherits the functionality, features, and styling of the parent theme (WordPress theme). Child themes let you change small details of your site's appearance while still preserving the parent theme's appearance and functionality. The child theme is designed to inherit the features and appearance of the parent theme, while also enabling the user to make modifications/alterations to any part of the theme.
14. Explain WordPress Taxonomies.
WordPress Taxonomies group content or data together in WordPress. Shortly, it allows you to organize/group your posts based on what they have in common (characteristics). Several default taxonomies are available, and you can also design your own. WordPress's Categories and Tags are two of its most popular taxonomies.
15. Explain Category and Tags in WordPress. How to convert a category into a tag?
Categorization and tags play a much greater role in the content organization as well as SEO.
- Categories: Essentially, categories are a general way to group content on a WordPress website. The idea of a category is to represent a topic or a group of topics that are somehow related to one another. A post can belong to several categories at once. Nevertheless, assigning more than two or three categories to one post is perhaps not the best idea.
- Tags: Tags provide a good way to identify a piece of content by specific keywords. Just choose a few words that best describe a given post.
16. What are meta tags?
Meta tags are snippets of HTML code that describe the content of a website or a specific webpage. Search engines use these bits of data to determine what a page is about, and they provide the content that shows up in search results. Although meta tags still provide the description displayed in search engine results, they contribute greatly to improving CTRs (Click-Through Rates).
17 : What are disadvantages of WordPress?
- Use of multiple plugins can make website heavy to load and slow
- Only utilizes PHP
- Sometimes updates can lead to loss of data, so you always need a backup copy
- Modifying images and tables are difficult.
WordPress’s query function allows you to execute any SQL query on the WordPress database. It is best used when there is a need for specific, custom, or otherwise complex SQL queries. For more basic queries, such as selecting information from a table, see the other wpdb functions above such as get_results, get_var, get_row or get_col.
Syntax
<?php $wpdb->query('query'); ?>
Read more from https://codex.wordpress.org/Class_Reference/wpdb#Running_General_Queries
20 : List some action and filter hooks functions in WordPress?
Below are list of some Filter hooks functions
- has_filter()
- add_filter()
- apply_filters()
- apply_filters_ref_array()
- current_filter()
- remove_filter()
- remove_all_filters()
- doing_filter()
Below are list of some Action hooks functions
- has_action()
- add_action()
- do_action()
- do_action_ref_array()
- did_action()
- remove_action()
- remove_all_actions()
- doing_action()
$loop = new WP_Query( $args );
while ( $loop->have_posts() ) : $loop->the_post();
the_title();
echo '<div class="entry-content">';
the_content();
echo '</div>';
endwhile;
Shortcodes in WordPress are specific codes that allow the developers to do various tasks with minimal effort. Shortcodes are used to simplify tasks such as creating objects or embedding files that require lots of coding in a single line. A Shortcode is synonymous to the shortcut. WordPress has five built-in shortcodes- audio, embed, caption, video, and gallery.
Example
1. You can call shortcode function like this :
echo do_shortcode('[display_related_posts]');
2. In your function.php you can make
function display_related_posts($array = array()) {
return 'BestInterviewQuestion.com';
}
add_shortcode('display_related_posts', 'display_related_posts');
A Sidebar in WordPress is an area where widgets can be used with a theme and this area is also termed as a Widgetized area. In WordPress, sidebar is created by using a function named as register_sidebar() function. The widget zed area should be registered in WordPress supported the theme as they are presentational. The sidebar function takes only one argument of an associative array of parameters that set the options for the widget area. Wrap $args array and register_sidebar() both are separate functions that can be called on ‘widgets_init’ hooks. In short, with the use of register_sidebar() method/ function users can add sidebars to WordPress. Syntax code for the creation of sidebar-$args = array(
'name' => __( 'Sidebar name', 'theme_text_domain' ),
'id' => 'unique-sidebar-id',
'description' => '',
'class' => '', 'before_widget' => '<li id="%1$s" class="widget %2$s">',
'after_widget' => '</li>',
'before_title' => '<h2 class="widgettitle">',
'after_title' => '</h2>'
);
38 : How does WordPress interact with databases?
There are many ways when WordPress can interact with databases like using functions like get_posts(), wp_get_post_terms(), wp_query(), and $wpdb(). From all these functions the most effective function to get a database table out of WordPress is the $wpdb() function. $wpdb is a global function and hence is declared with global keyword.
global $wpdb;
39 : How to Create a Widget in WordPress?
Widget is defined as a configurable code snippet which makes it possible to customize the functionality and appearance of a WordPress blog. Users can access the widgets page form the appearance menu effectively. Widgets in WordPress allow you to drag and drop the elements into the sidebar of your website. WordPress is featured with a standard set of widgets that you can use with any theme of WordPress. In order to create a customer widget in WordPress, it is important for the customers.
- In order to create a site-specific plugin, paste the code functions .php file (theme’s file)
- add your code to appearance >> widgets pages
- register with ‘wpb_widget’ and load customer widgets
Here is a list of some best picks which we think will do the honors. Name any 3-4 and be sure to study about them in brief.
- Yoast SEO
- Google XML sitemaps
- SEO framework
- SEO squirrely
- WP meta SEO
- Rank Math
- SEO press
- AIOSEO (All In One SEO)
1. Actions Hook
Actions Hook are triggered by particular events that take place in WordPress such as changing themes, publishing a post, or displaying an administration screen. It is a custom PHP function defined in your plugin and hooked, i.e., set to respond, to some of these events.
Actions offently do one or more of the following things
- Modify database data
- Send an email message
- Modify the generated administration screen or front end page sent to a user web browser.
Here are some Actions Functions listed
- has_action()
- do_action()
- add_action()
- remove_action() etc
2. Filters Hook
Filters Hook are functions that WordPress passes data through, at certain points in execution, just before taking some action with the data. It sits between the database and the browser and between the browser and the database; all most all input and output in WordPress pass through at least one filter hook.
The necessary steps to add your filters to WordPress are listed:
- Create the PHP function that filters the data
- Hook to the screen in WordPress, by calling add_filter()
- Put your PHP function in a plugin file and activate it.
Here are some Filters Functions listed
- has_filter()
- doing_filter()
- add_filter()
- remove_filter() etc
Step 1: Create a child theme folder.
Step 2: Create a stylesheet for your child theme.
Next, you’ll need to create a stylesheet file to contain all of the CSS rules and declarations for your child theme. To do so, create a new text file and name it “style.css.”
You’ll have to add a required header comment at the very top of the file in order for the stylesheet to actually work. This comment contains basic info about the child theme, including that it is a child theme with a particular parent theme.
You really only need to include two things: the theme name and template (ie. the parent theme’s name). You can include other information, including a description, author name, version, and tags. These additional details are important if you’re going to publish or sell your child theme.
Here’s an example of a complete header comment for a Twenty Twenty-One child theme:
/*Theme Name: Twenty Twenty-One
Theme URI: https://example.com/twenty-twenty-one-child/
Description: Twenty Twenty-One Child Theme
Author: Anna Fitzgerald
Author URI: https://example.com
Template: twentytwentyone
Version: 1.0.0
License: GNU General Public License v2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Tags: two-column, responsive-layout
Text Domain: twentytwentyonechild
*/
Notice the slashes and asterisks. These signify that this code will be “commented out” in CSS so WordPress doesn’t try to execute it.
You can add custom CSS later when you’re ready to begin customizing your child theme. For now, click Save so this stylesheet will be saved in your child theme’s directory.
Step 3: Enqueue the parent and child themes’ stylesheets.
Now it’s time to enqueue your parent and child themes’ stylesheets. This will ensure two things: First, that the child theme inherits its parent theme’s styling so when you activate your child theme, you’re not just looking at a bunch of unstyled text.
Second, that the child theme’s stylesheet is loaded before the parent theme’s — without overriding it. That way, once you add custom CSS and otherwise modify your child theme, these modifications will augment or replace certain styles and functions of the parent theme.
To do so, create another file in your child theme’s directory. Name it “functions.php” and add the following code:
<?php
add_action( 'wp_enqueue_scripts', 'enqueue_parent_styles' );
function enqueue_parent_styles() {
wp_enqueue_style( 'parent-style', get_template_directory_uri().'/style.css' );
}
?>
Step 4: Install and activate your child theme.
You install a child theme the same way you install any theme. You have two options: you can copy the folder to the site using FTP, or create and upload a zip file of the child theme folder.
To upload the file, go to your WordPress dashboard and click on Appearance > Themes > Upload. Then, choose your child theme’s directory
Once it’s uploaded, click Activate.
Good news: your child theme is now live! The only problem is that it looks exactly like your parent theme. It’s time to customize.
Step 5: Customize your child theme.
To customize your child theme, you’ll likely start by adding CSS to the style.css file in your child theme’s directory. It’s one of the easiest ways to make changes to your theme. Whether you want to customize the color scheme, padding, typography, or other fundamental design elements of the parent theme, simply add code to your child theme’s stylesheet below the header comment. This code will override the code in your parent theme’s stylesheet.
To modify the functionality of the parent theme, on the other hand, you need to add functions to the functions.php file in your child theme’s directory.
For example, if you want to allow writers and other users to format their posts in different ways, then you can use the add_theme_support() function. To allow them to format posts as notes, links, a gallery of images, quotes, a single image, or video, then you’d add the following to your functions.php file in your child theme directory:
add_theme_support( 'post-formats', array ( 'aside', 'gallery', 'quote', 'image', 'video' ) );
You can put as many or as few functions as you want between the opening and closing PHP tags of your file.
No comments:
Post a Comment