Banner Image

Essential function in WordPress

Dashrath Singh
April 29, 2021
1 Minute Read

scroll

down

Banner Image

Looking for other services or solutions?

ux/ui image
Explore our services

IN A nutshell

Next.js

Next.js is a React framework that supports pre-rendering. Instead of having the browser render everything from scratch, Next.js can serve pre-rendered HTML in two different ways:

IN A nutshell

SSR

SSR: It generates HTML file on each request. This is useful if your page is having dynamic data which is frequently changing.

  • the_title():Display or retrieve the current post/page title with optional markup
  • the_content():-Display the post content.
  • the_field():-display the post/page content.
  • get_field():-Returns the value of a specific field.
echo get_field(“field_name” ); echo get_field(“field_name”,post_ID );

This example shows how to load the value of field ‘text_field’ from the current post.

$value = get_field( “text_field” ); Get a value from specific post.
$value = get_field( “text_field”, 123 ); check if value exits.
$value = get_field( “text_field” ); if( $value ) { echo $value; } else { echo ’empty’; }
  • the_post_thumbnial():- Display the post thumbnail.

functionthe_post_thumbnail( $size= ‘post-thumbnail’, $attr= ”) {echoget_the_post_thumbnail( null, $size, $attr);}

  • the_permalink():- Displays the permalink for the current post.

//for particular post id.

  • wp_trim_words():-Trims text to a certain number of words.

wp_trim_words( string $text, int $num_words = 55, string $more = null )

  • The basic loop :- The have_post() function checks whether there are any posts. 9.the_author():-Display the name of the author of the current post.
  • the_date():-Display or Retrieve the date the current post was written

(once per date).

  • get_the_date():-Retrieve the date on which the post was written.
  • get_the_date( null,get_the_ID() );

Example:-

  • get_header():-Load the header template.
  • get_footer():-Load the footer template.
  • get_template_part()-get a template part into the template.

get_template_part(“file_name”);

echo get_field(“field_name” ); echo get_field(“field_name”,post_ID );

This example shows how to load the value of field ‘text_field’ from the current post.

$value = get_field( “text_field” ); Get a value from specific post.
$value = get_field( “text_field”, 123 ); check if value exits.
$value = get_field( “text_field” ); if( $value ) { echo $value; } else { echo ’empty’; }

functionthe_post_thumbnail( $size= ‘post-thumbnail’, $attr= ”) {echoget_the_post_thumbnail( null, $size, $attr);}

//for particular post id.

wp_trim_words( string $text, int $num_words = 55, string $more = null )

(once per date).

Example:-

get_template_part(“file_name”);

-->
0 Shares
Tweet
Share
Share
Pin