WordPress Template Tags You May Not Know

Spread the love

10 WordPress Template Tags You May Not Know

WordPress is delivered with a significant wealth of Template Tags since its origin. These Template Tags in WordPress are PHP capacities that can be utilized to yield and recover a bit of information.

On the off chance that you have been building up a WordPress topic, you might be acquainted with some of these Template Tags, for example, the_title that demonstrates the post title, the_author that demonstrates the name of the post’s creator, and the connection of the post.

WordPress continues advancing. Each new discharge frequently presents a couple of new Template Tags. To such an extent that staying aware of all these Template Tags — old or new — can be very testing. Look at the these 20 format labels you may have disregarded.

Get Theme

This function recovers a question containing data of the presently dynamic Theme. This data incorporates the topic Slug, Name, Version, Text Domain, Author, and so forth.

In the accompanying code bit, we utilize it to recover the rendition and pass it as the script adaptation.

Since: 3.4.0


Get the Avatar Image URL

As the name proposes, this Template Tag, get_avatar_url(), will recover the picture way of the client’s symbol. It permits you to show and form the symbol in any capacity you like, rather than basically showing it through the HTML picture tag.

Since: 4.2.0


Dropdown Language

The wp_dropdown_languages Template Tag will yield a HTML alternative demonstrating a rundown of dialects in your WordPress site. You will discover this format tag valuable on the off chance that you have to limit your site. You can utilize it to demonstrate your dialect choices in the User Editor screen or in the front-end of your site to permit clients to choose their dialect inclination.

Since: 4.0.0


Add Inline Scripts

We have constantly utilized the wp_enqueue_script to enroll, stack a script and its conditions. Stacking an interior script however was not exactly direct, until this Template Tag, wp_add_inline_script is presented.

Including an inline script requires a known enqueued script to which it will be connected. This handler is passed as the principal parameter of the script like the wp_localize_script() work. The second parameter ought to pass the substance of the script. The third parameters specifiy whether the inline ought to be yield “before” or “after” .

Since: 4.5.0


Shortening URL

This Template Tag will abbreviate a url length. What’s more, such a long URL won’t break into another line inside the body content. There are 2 alternatives you can take: include flood wrap: break-word; in your CSS, or trim the length of the URL with the url_shorten() Template Tag.

Since: 1.2.0


Comments Pagination

Most Themes are right now utilizing the the_comments_navigation() which will give the “Following” and “Prev” kind of route connection. On the off chance that you need to demonstrate a numbered route (pagination), supplant the tag with the_comments_pagination.

Remember that the Template Tag is just accessible in WordPress 4.4.0 upwards. Try to run a check before conveying it.

Since: 4.4.0


Generate Random Number

This Template Tag will give you a random number based on a specified range. WordPress is using this function internally to generate a random password. You can probably use it to generate a random coupon number for your WooCommerce site.

Since: 2.6.2


Thumbnail Image URL

WordPress has a long-integrated, native utility to add a thumbnail image or featured image. The Template Tag, the_post_thumbnail(), shows the image tag along with their attributes.

But what if you want to show the image thumbnail as a background through CSS instead? Use the Template Tag, get_the_post_thumbnail_url().

Since: 4.4.0


Custom Logo

In 4.5, WordPress introduced the ability to upload a logo for themes through the Customizer. This new feature requires theme support: by adding add_theme_support( 'site-logo' ), the logo will appear in the Customizer.

This feature leads to the use of a few new Template Tags that can handle the logo image output on Themes, namely: has_custom_logo(), get_custom_logo(), and the_custom_logo().

Since: 4.5.0


Capital P

WordPress, as per their guideline and standard, has to be written with the capital P i.e. WordPress is a no no; the right way is to spell it as WordPress.

The capital “P” is an issue with so much importance to the extend that Matt Mullenweg (founder of WordPress) has included it in his resolution back in 2009. The capital_p_dangit() function is introduced as part of the initiative.

Since: 3.0.0


Leave a Reply

Your email address will not be published. Required fields are marked *