Essential function in WordPress
- 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”);