پارسی

What is WordPress function? Complete list of WordPress functions

What is WordPress function? Complete list of WordPress functions

Probably those who work with WordPress in the field of website design have heard terms like WordPress functions a lot. Now, many people may not know what the WordPress function is and what it is used for. In this article, we are trying to talk about WordPress functions while defining WordPress and its use, and then introducing a list of the most important WordPress functions. Therefore, if you also want to get information about this topic, I suggest you stay with us until the end of the article.

What is WordPress and what is it used for?

WordPress is one of the most common and easiest ways to build a website. Today, no one is not aware of the advantages of having a website, given that all businesses have gone virtual. Therefore, having a website to provide services and introduce and expand your business is one of the necessities. Many people may think that building and running a website is a very difficult and expensive job. But, thanks to the WordPress content management system, this is very simple and cost-effective. Today, more than 40% of the world’s websites are built with WordPress.

WordPress is a free, open-source, web-based content management system for setting up and building websites. This content system has many advantages and positive features, among which the following can be mentioned:

WordPress is free

WordPress is a website builder content management system that you can install completely free of charge and start your site with.

Ease of installation

One of the very positive features and benefits of the WordPress content management system is its simplicity and ease of installation so that you can install and activate it in less than 5 minutes. For its installation method, just search a little on the internet and follow the installation steps easily.

Easy and convenient to use

Another popular feature of WordPress is its ease of use. This means that you can easily design your site without knowing coding or programming knowledge. You can also use ready-made WordPress templates for more advanced and faster site design.

Another feature of WordPress is its constant updating. This system is constantly being updated according to the needs of its users and the advancement of technology so that it can meet all the needs of its audience. At the same time, it is necessary to remember that WordPress does not charge you for these updates.

Constantly updating WordPress

Another feature of WordPress is its constant updating. This system is constantly being updated according to the needs of its users and the advancement of technology so that it can meet all the needs of its audience. At the same time, it is necessary to remember that WordPress does not charge you for these updates.

Has free plugins

You can add many different features to your site with plugins. Many free plugins in WordPress add the right features to your site. Of course, many non-free plugins add more advanced features and functionality to your site.

Easy site optimization or SEO

Another advantage of WordPress that adds to its popularity is the presence of plugins that help you optimize your site for search engines. Among the most famous of these plugins, you can mention Yost SEO and RankMath plugins, which have a free versions. Of course, the non-free version of these plugins provides you with more features and capabilities.

WordPress open source

WordPress is completely open source.

Building all kinds of sites with WordPress

There is no limit to the types of sites WordPress can create. You can create all kinds of the store, news, educational, corporate, job search, photography, etc. sites with WordPress.

Now that we have reviewed WordPress and its features and benefits, we are going to answer the question, what are the functions of WordPress? Before answering this question, it should be said that WordPress is created by the PHP programming language (PHP) and WordPress functions are created by a series of PHP programming code pieces. Each WordPress plugin or theme uses WordPress functions to display its dynamic information. To better understand this issue, it is necessary to first explain what a function is in programming science.

What is a function in programming?

A function in programming is a piece of independent code that performs a specific task. The process of data in programming is that they receive a series of data and return the result after processing the data. The good feature of functions is that they are written once and can be used over and over again.

In simpler terms, a programmer writes a function and chooses a name for it so that later he can call the function by this name. Calling the function means that the task that the function is supposed to perform is performed and the result is returned. For example, you write a function that calculates the factorial of a number for you. In this case, you will find the answer to your question with a small piece of code and you don’t need to write a long program to calculate the factorial.

What is a WordPress function?

What is a WordPress function?
What is a WordPress function?

Considering that we said more than WordPress is written with PHP programming language. This programming language supports the function. So we have many functions in WordPress. Using WordPress functions, we can create any features we want in WordPress. Some developers may design these functions in the form of a plugin or theme, in which case all you need to do is download that plugin or theme and install it on your WordPress.

How should we use WordPress functions?

To use WordPress functions, it is necessary to be familiar with the WordPress programming language first. Learning the WordPress language is not a difficult task and with a search on the internet you can see all kinds of tutorials about it and in this way get to know the basic concepts of PHP programming. Now, to be able to use a pre-defined function in WordPress, you must first know the name of that function and then write the name of the function along with an open and closed parenthesis, this is called calling the function.

Where should we use WordPress functions?

If you are a WordPress developer, you can use WordPress functions in two places, one is in the WordPress plugin and the other is the WordPress template. 

In a WordPress plugin, we may have a large number of PHP files that host PHP codes, including these WordPress functions. For a WordPress plugin, there must be a main document named after the plugin itself. Now, apart from that document, there can be other PHP files, all of which should be placed in the same main folder of the plugin.

An example of using functions in WordPress
An example of using functions in WordPress

But for a WordPress theme, there is a main document called functions.php, where WordPress functions should be placed in that document. Now, apart from this document, you can create other files that have WordPress functions with PHP extension. But the main thing is that all of them should be embedded in the main functions.php document, which is located in the root path of the template folder. Otherwise, WordPress cannot know how to call these functions.

Of course, you need to know that besides these functions that are already written and we call them. We can also write our arbitrary functions. 

What is the use of WordPress functions?

The functions defined in WordPress are defined to prevent repetition and create errors and problems in programming, and these functions help you to access different parts of the WordPress core and make changes and control it in a standard way. In the rest of the article, we will introduce essential and frequently used functions of WordPress.

Complete list of WordPress functions

Now that we are familiar with WordPress functions, let’s review a list of WordPress functions together:

Basic and basic functions of WordPress

In this section, we introduce functions that automatically print and display something.

<?php bloginfo('name'); ?> display the title of the website
 
<?php bloginfo('description');?> (display a short introduction of your site (description of the site
 
<?php bloginfo('admin_email');?> Display admin email address
 
<?php bloginfo('url');?> display website address
 
<?php bloginfo('wpurl');?> Display WordPress site URL
 
<?php bloginfo('stylesheet_url');?> display the URL of the CSS file in the active shell folder    
 
<?php bloginfo('template_directory'); ?> Display the address of the active shell folder
 
<?php bloginfo('atom_url'); ?> Display the site atom feed address
 
<?php bloginfo('rss_url'); ?> Display the website's RSS address
 
<?php bloginfo('rss2_url'); ?> display the website's RSS 2 address
 
<?php bloginfo('rdf_url'); ?> display the RDF address of the site
 
<?php bloginfo('charset'); ?> Display the Unicode used on your website
 
<?php bloginfo('language'); ?> Display the active language used on your website
 
<?php bloginfo('text_direction');?> Display the direction used on your website
 
<?php bloginfo('version'); ?> Display the WordPress version of your website
 
<?php wp_title(); ?> Display the title of the page being displayed
 
<?php get_search_form() ?> Display the search form on the site
 
<?php the_search_query() ?> Display the searched text after searching the site
 
<?php wp_tag_cloud(); ?> Display the complete list of tags used on the website
 
<?php echo tag_description(id); ?> Display the description of a specific tag - instead of ID, enter the tag ID
 
<?php single_tag_title(); ?> Display the name of the tag that we clicked on and entered the tag page
 
<?php single_post_title(); ?> Display the name of the article that we clicked on and entered the page
 
<?php single_cat_title(); ?> Display the name of the category that we clicked on and entered its page
 
<?php the_permalink(); ?> Show unique link
 
<?php get_calendar(); ?> Display the calendar on the website

Functions of drop-down menus and lists

In this section, we will introduce the list of functions that display simple and cascading lists.

<?php wp_dropdown_categories(); ?> display topics in the form of a drop-down menu
 
<?php wp_dropdown_pages(); ?> display pages in the form of a drop-down menu
 
<?php wp_dropdown_users(); ?> Show users in the form of a drop-down menu
 
<?php wp_get_archives(); ?> Display the website archive list
 
<?php wp_list_authors(); ?> Display the list of website authors
 
<?php wp_list_bookmarks(); ?> Display a list of website links
 
Note: By default, the possibility of inserting a link in WordPress is disabled, to enable this possibility, you must add the following code in your theme's function file.
 
add_filter( 'pre_option_link_manager_enabled', '__return_true' );
 

 
<?php wp_list_categories(); ?> Display the list of website topics
 
<?php wp_list_comments(); ?> Display the list of website comments
 
<?php wp_list_pages(); ?> Display the list of website tabs
 
<?php wp_page_menu(); ?> Display the list of website pages

Entry and exit functions

In this section, we show the list of functions that are used to enter and exit users with different site roles.

<?php wp_login_form(); ?> Display the login form to the website
 
<?php echo wp_login_url(); ?> display the address of the login section of the site
 
<?php echo wp_logout_url(); ?> Display the exit address from the website
 
<?php echo wp_lostpassword_url(); ?> display the address of the forgotten password section of the website
 
<?php echo wp_registration_url(); ?> Display the address of the registration section on the website
 
<?php wp_loginout(); ?> Display the login/exit link automatically on the website
 

 
Conditional function for two conditions of login as guest or login with username
<?php
if ( is_user_logged_in() ) {
    Features if the user was logged in
} else {
    Facilities if the user was a guest
}
?>

Writing functions

In the list below, we have functions related to displaying content and presenting them on pages to users.

Note: You must put the following functions in the WordPress loop.

Loop means a conditional tag that must contain the posts of a WordPress site, otherwise, the posts cannot be displayed.

<?php
	if ( have_posts() ) {
		while ( have_posts() ) {
			the_post(); ?>
                           Location of writing functions
<?php } // end while
	} // end if
?>
<?php posts_nav_link(); ?> Display the help to go to the next and previous page
 
<?php previous_post_link(); ?> Show link to previous post
 
<?php next_post_link(); ?> show the link to the next post
 
<?php the_category(); ?> Display the list of topics related to the current post
 
<?php the_permalink(); ?> Display the unique link of the desired page
 
<?php the_title(); ?> Display the title of the current post
 
<?php the_content(); ?> Display the contents of the current post
 
<?php the_excerpt(); ?> Brief display of the contents of the displayed post
 
<?php the_time(); ?> Display the time of the post being displayed
 
<?php the_date('y/m/d'); ?> Display the current post insertion date
 
<?php the_ID(); ?> Display ID of the currently displayed post
 
<?php the_author_posts(); ?> Display the number of posts by the author of the desired post
 
<?php the_author() ?> Display the name of the author of the desired post
 
<?php the_shortlink(); ?> Display the login link to the single page of the post being displayed
 
<?php the_tags(); ?> Display tags of the currently displayed post
 
<?php comments_number(); ?> Display the number of comments given on the post being displayed
 
<?php comments_template(); ?> single.php show the comments section - must be inside the file
 
<?php the_title_attribute(); ?> Display the attribute value of the title of the post being displayed

Knuckle functions

In the list below, we show you the codes related to the index image of each article, post, etc. in WordPress.

First, put the following function in the functions.php file and then use the following functions.

echo add_theme_support( 'post-thumbnails' );
<?php the_post_thumbnail('thumbnail'); ?> Show thumbnail for each post or tab - default size 150x150
 
<?php the_post_thumbnail('medium'); ?> Show thumbnail for each post or tab - default size 300x300
 
<?php the_post_thumbnail('large'); ?> Show thumbnail for each post or tab - default size 640x640
 
<?php the_post_thumbnail('full'); ?> display the thumbnail of each post or page in original size
 
In addition, the above 4 functions are for display in standard sizes. To cut the uploaded photo and display it on the website, you must do the following.
 
1- Add the following code in the function file
 

 
if (function_exists('add_image_size')):
add_image_size('your-name',width,height,true);
endif;
 

 
2- Put the following code to display the thumbnail
 
<?php the_post_thumbnail('your-name'); ?>

tip! In the above codes instead of:

width: photo width (number)

height: photo height (number)

And instead of your name: put your desired name.

List functions and menus

In the list below, we show you the functions that are related to the list and resources in WordPress.

View website listings
 
<?php wp_nav_menu( array( 'theme_location' => 'mabnawp-Nav', 'menu_class' => 'navbar' ) ); ?>
 
Note: This feature is disabled by default, and to enable it, you must put the following function in the function file.
 
function register_my_menu() {
  register_nav_menu('mabnapw-Nav',__( 'mabnawp-Nav' ));
}
add_action( 'init', 'register_my_menu' );

tip :

Start a navbar class in CSS and start designing your list.

Placement and inclusion functions

In this list, you can see the functions related to the embedding functions in WordPress.

<?php get_header(); ?> Include header
 
<?php get_footer(); ?> Include footer
 
<?php get_sidebar(); ?> Include sidebar
 
<?php get_template_part('bistscript'); ?>

You can also get a more complete list of WordPress functions here.

Conclusion

WordPress has thousands, thousands of functional functions that are often used in WordPress core. Some of these functions are designed and implemented for the main and important functions of WordPress, and some others are designed and implemented for use by designers of WordPress templates and plugins. In this article, we talked to you completely about WordPress functions and its services. And finally, we introduced the most important and practical functions of WordPress. I hope this article was useful for you.

What do you think?